Skip to content

passing around pool or connection? #316

Answered by blackbeam
conormdowney asked this question in Q&A
Discussion options

You must be logged in to vote

Hi.

Is the expectation that you would create a pool from a url and pass that around.

Yeah, this is the expectation, but pool won't close used connections (at least in cases where they don't violate pool constraints).
Usually I'm not passing it around but create one as a static reference.

Or can you create a single connection that can be passed into various classes and all would use the same connection to query?

This is only practical for cases where you don't need to execute multiple queries at the same time. You should also note, that Conn can't be cloned.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by blackbeam
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants