Skip to content

Commit a496413

Browse files
authored
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()`.
1 parent 2f5ba71 commit a496413

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

sqlx-sqlite/src/options/mod.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,19 @@ use sqlx_core::IndexMap;
4141
/// ```rust,no_run
4242
/// # async fn example() -> sqlx::Result<()> {
4343
/// use sqlx::ConnectOptions;
44-
/// use sqlx::sqlite::{SqliteConnectOptions, SqliteJournalMode};
44+
/// use sqlx::sqlite::{SqliteConnectOptions, SqliteJournalMode, SqlitePool};
4545
/// use std::str::FromStr;
4646
///
47-
/// let conn = SqliteConnectOptions::from_str("sqlite://data.db")?
47+
/// let opts = SqliteConnectOptions::from_str("sqlite://data.db")?
4848
/// .journal_mode(SqliteJournalMode::Wal)
49-
/// .read_only(true)
50-
/// .connect().await?;
49+
/// .read_only(true);
50+
///
51+
/// // use in a pool
52+
/// let pool = SqlitePool::connect_with(opts).await?;
53+
///
54+
/// // or connect directly
55+
/// # let opts = SqliteConnectOptions::from_str("sqlite://data.db")?;
56+
/// let conn = opts.connect().await?;
5157
/// #
5258
/// # Ok(())
5359
/// # }

0 commit comments

Comments
 (0)