Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve pool use documentation? #198

Open
stephencelis opened this issue Oct 6, 2020 · 2 comments
Open

Improve pool use documentation? #198

stephencelis opened this issue Oct 6, 2020 · 2 comments

Comments

@stephencelis
Copy link

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?

@0xTim
Copy link
Member

0xTim commented Nov 2, 2020

@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

@gwynne
Copy link
Member

gwynne commented Nov 2, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants