Skip to content

Commit

Permalink
doc(sqlite): show how to turn options into a pool (#3508)
Browse files Browse the repository at this point in the history
It took me 15 minutes of messing around and googling to find
`.connect_with()`.
  • Loading branch information
M3t0r authored Sep 16, 2024
1 parent 2f5ba71 commit a496413
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions sqlx-sqlite/src/options/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
/// # }
Expand Down

0 comments on commit a496413

Please sign in to comment.