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:
parent
2f5ba71c1e
commit
a496413cb6
1 changed files with 10 additions and 4 deletions
|
@ -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(())
|
||||
/// # }
|
||||
|
|
Loading…
Add table
Reference in a new issue