mirror of
https://github.com/launchbadge/sqlx
synced 2024-11-10 06:24:16 +00:00
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
|
/// ```rust,no_run
|
||||||
/// # async fn example() -> sqlx::Result<()> {
|
/// # async fn example() -> sqlx::Result<()> {
|
||||||
/// use sqlx::ConnectOptions;
|
/// use sqlx::ConnectOptions;
|
||||||
/// use sqlx::sqlite::{SqliteConnectOptions, SqliteJournalMode};
|
/// use sqlx::sqlite::{SqliteConnectOptions, SqliteJournalMode, SqlitePool};
|
||||||
/// use std::str::FromStr;
|
/// use std::str::FromStr;
|
||||||
///
|
///
|
||||||
/// let conn = SqliteConnectOptions::from_str("sqlite://data.db")?
|
/// let opts = SqliteConnectOptions::from_str("sqlite://data.db")?
|
||||||
/// .journal_mode(SqliteJournalMode::Wal)
|
/// .journal_mode(SqliteJournalMode::Wal)
|
||||||
/// .read_only(true)
|
/// .read_only(true);
|
||||||
/// .connect().await?;
|
///
|
||||||
|
/// // 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(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
|
|
Loading…
Reference in a new issue