简体   繁体   中英

How do you manage Postgresql database connections in Rails?

I am using Upsert in a Rails app and as a result there are a number of Postgresql connections that I am creating on my own:

connection = PG.connect(dbname: db_name)
Upsert.batch(connection, :items) do |upsert|
  ...
end

I'm wondering, is there a better way to manage these connections? Do these connections need to be closed in some way?

No, you don't need to close the connection manually. Please check this - https://github.com/seamusabshere/upsert

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM