-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
can't send PooledConnection reference #2232
Comments
That's by "design". The underlying connection is just not threadsafe, so it cannot be shared between threads. |
For anyone else running into this: what you probably want to do is to share a Example 1 async fn execute(pool: &Pool<ConnectionManager<PgConnection>>, data: SomeData) -> Result<(), Error> {
diesel::insert_into(some_table)
.values(data)
.execute(&pool.get()?)?;
Ok(())
} Example 2 pub struct Database {
pool: Pool<ConnectionManager<PgConnection>>,
}
impl Database {
async fn insert_some_data(&self, data: SomeData) -> Result<(), Error> {
diesel::insert_into(some_table)
.values(data)
.execute(&self.pool.get()?)?;
Ok(())
}
} See |
thanks for the &pool.get() |
I'm trying to wrap
PooledConnection
in the Mutex and getting this:Apparently I can't pass reference to a connection?
The text was updated successfully, but these errors were encountered: