mirror of
https://github.com/launchbadge/sqlx.git
synced 2026-03-21 01:23:59 +00:00
Add a "sqlite-unbundled" feature that dynamically links to system libsqlite3.so library (#3507)
* Add a "sqlite-unbundled" feature that dynamically links to system libsqlite3.so library * update README abouot the newly-added `sqlite-unbundled` feature * Update README.md to make it clear with bulleted list Co-authored-by: Austin Bonander <austin.bonander@gmail.com> * more cfg feature updates Co-authored-by: Austin Bonander <austin.bonander@gmail.com> * update documentation in sqlx-sqlx/src/lib.rs too and also mention possible build time increasement. * cargo fmt * Add "sqlite-unbundled" feature to sqlx-cli * Add sqlite-unbundled to gituhb actions tests * cfg(feature = "sqlite") => cfg(any(feature = "sqlite", feature = "sqlite-unbundled")) * fix * CI: make sqlite-unbundled tests workaround required-features by duplicating the relevant test section * use an internal "_sqlite" feature to do the conditional compilation --------- Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
This commit is contained in:
@@ -57,6 +57,7 @@ native-tls = ["sqlx/runtime-tokio-native-tls"]
|
||||
mysql = ["sqlx/mysql"]
|
||||
postgres = ["sqlx/postgres"]
|
||||
sqlite = ["sqlx/sqlite"]
|
||||
sqlite-unbundled = ["sqlx/sqlite-unbundled"]
|
||||
|
||||
# workaround for musl + openssl issues
|
||||
openssl-vendored = ["openssl/vendored"]
|
||||
|
||||
@@ -19,6 +19,9 @@ $ cargo install sqlx-cli --features openssl-vendored
|
||||
|
||||
# use Rustls rather than OpenSSL (be sure to add the features for the databases you intend to use!)
|
||||
$ cargo install sqlx-cli --no-default-features --features rustls
|
||||
|
||||
# only for sqlite and use the system sqlite library
|
||||
$ cargo install sqlx-cli --no-default-features --features sqlite-unbundled
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -11,7 +11,7 @@ pub async fn create(connect_opts: &ConnectOpts) -> anyhow::Result<()> {
|
||||
let exists = crate::retry_connect_errors(connect_opts, Any::database_exists).await?;
|
||||
|
||||
if !exists {
|
||||
#[cfg(feature = "sqlite")]
|
||||
#[cfg(feature = "_sqlite")]
|
||||
sqlx::sqlite::CREATE_DB_WAL.store(
|
||||
connect_opts.sqlite_create_db_wal,
|
||||
std::sync::atomic::Ordering::Release,
|
||||
|
||||
@@ -258,7 +258,7 @@ pub struct ConnectOpts {
|
||||
/// However, if your application sets a `journal_mode` on `SqliteConnectOptions` to something
|
||||
/// other than `Wal`, then it will have to take the database file out of WAL mode on connecting,
|
||||
/// which requires an exclusive lock and may return a `database is locked` (`SQLITE_BUSY`) error.
|
||||
#[cfg(feature = "sqlite")]
|
||||
#[cfg(feature = "_sqlite")]
|
||||
#[clap(long, action = clap::ArgAction::Set, default_value = "true")]
|
||||
pub sqlite_create_db_wal: bool,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user