From 405474b5750a116e9bd4ec496ddfe78206d52ccb Mon Sep 17 00:00:00 2001 From: link2xt Date: Wed, 28 Apr 2021 04:35:45 +0300 Subject: [PATCH] sqlite: add SqliteConnectOptions::shared_cache() (#1177) This makes it possible to open database in shared cache mode without having to construct `sqlite://` URL with `?cache=shared` flag. --- sqlx-core/src/sqlite/options/mod.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sqlx-core/src/sqlite/options/mod.rs b/sqlx-core/src/sqlite/options/mod.rs index d86a0650..ba50bc05 100644 --- a/sqlx-core/src/sqlite/options/mod.rs +++ b/sqlx-core/src/sqlite/options/mod.rs @@ -105,6 +105,14 @@ impl SqliteConnectOptions { self } + /// Set the [`SQLITE_OPEN_SHAREDCACHE` flag](https://sqlite.org/sharedcache.html). + /// + /// By default, this is disabled. + pub fn shared_cache(mut self, on: bool) -> Self { + self.shared_cache = on; + self + } + /// Sets the [journal mode](https://www.sqlite.org/pragma.html#pragma_journal_mode) for the database connection. /// /// The default journal mode is WAL. For most use cases this can be significantly faster but