doc(sqlite): show how to turn options into a pool (#3508)

It took me 15 minutes of messing around and googling to find
`.connect_with()`.
This commit is contained in:
Simon Brüggen 2024-09-16 06:38:00 +02:00 committed by GitHub
parent 2f5ba71c1e
commit a496413cb6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -41,13 +41,19 @@ use sqlx_core::IndexMap;
/// ```rust,no_run
/// # async fn example() -> sqlx::Result<()> {
/// use sqlx::ConnectOptions;
/// use sqlx::sqlite::{SqliteConnectOptions, SqliteJournalMode};
/// use sqlx::sqlite::{SqliteConnectOptions, SqliteJournalMode, SqlitePool};
/// use std::str::FromStr;
///
/// let conn = SqliteConnectOptions::from_str("sqlite://data.db")?
/// let opts = SqliteConnectOptions::from_str("sqlite://data.db")?
/// .journal_mode(SqliteJournalMode::Wal)
/// .read_only(true)
/// .connect().await?;
/// .read_only(true);
///
/// // use in a pool
/// let pool = SqlitePool::connect_with(opts).await?;
///
/// // or connect directly
/// # let opts = SqliteConnectOptions::from_str("sqlite://data.db")?;
/// let conn = opts.connect().await?;
/// #
/// # Ok(())
/// # }