passing around pool or connection? #316
-
Pretty new to rust so apologies for anything silly. I see in the documentation it says about Pools But its on a connection where queries are executed. So is the expectation that you would create a pool from a url and pass that around, and when a query needs to be executed a connection is created and the query is executed and the connection is closed. Or can you create a single connection that can be passed into various classes and all would use the same connection to query? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi.
Yeah, this is the expectation, but pool won't close used connections (at least in cases where they don't violate pool constraints).
This is only practical for cases where you don't need to execute multiple queries at the same time. You should also note, that |
Beta Was this translation helpful? Give feedback.
Hi.
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.
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.