postgres-kit
postgres-kit copied to clipboard
Improve pool use documentation?
The README currently shows how to get a database from a pool:
let postgres = pool.database(logger: ...) // PostgresDatabase
let rows = try postgres.simpleQuery("SELECT version();").wait()
Should you go through pool whenever you want to query? Or can you keep postgres around and use it for all of your queries?
@gwynne is the best person to answer, however I think storing postgres (in a thread-safe way, e.g. on an event loop) should be fine
In this context, the database connection stays open as long as postgres is alive (e.g. has at least one strong retain left on it). If it gets stored somewhere, you have to ensure you also eventually remove it from the storage; in particular, it must be released before the event loop that it runs on is shut down.