sqlite
sqlite copied to clipboard
sharing connection between threads
Great light weight library!
I'm trying to use share a Connection between threads (with sqlite::Connection::open_with_flags and flag set_full_mutex() which corresponds to the serialized multi-thread mode of sqlite3, which allows sharing a connection between threads - works well in C)
The sqlite connection is wrapped in an Arc and rustc gives the "(dyn FnMut(usize) -> bool + 'static)
cannot be shared between threads safely" error with "note: required because of the requirements on the impl of Send
for Arc<Connection>
"
Am I missing something? The sqlite serialized mode is allowed in open_with_flags so it would be logical to allow sharing the connection between threads
Thanks!
Hello, thank you for the question! I think it was added along with several other flags, and nobody really tested this particular scenario. Please feel free to correct and open a pull request.
It is available as of 0.27.2. Here is an example:
https://github.com/stainless-steel/sqlite/blob/main/tests/lib.rs#L81-L99