Skip to content

How do I run a few PRAGMAs against SQLite when the connection is created? #363

Closed Answered by tibbe
tibbe asked this question in Q&A
Discussion options

You must be logged in to vote

Here's what I finally came up with with @bikeshedder's help:

    let pool = deadpool_diesel::sqlite::Pool::builder(manager)
        .post_create(Hook::async_fn(|obj, _| {
            Box::pin(async move {
                let res = obj
                    .interact(|conn| {
                        conn.batch_execute(
                            r#"
                            PRAGMA journal_mode = WAL;
                            PRAGMA synchronous = NORMAL;
                            PRAGMA foreign_keys = ON;
                            PRAGMA busy_timeout = 5000;
                            "#,
                        )
                    })
                    .await;
                m…

Replies: 3 comments 12 replies

Comment options

You must be logged in to vote
3 replies
@bikeshedder
Comment options

@tibbe
Comment options

@bikeshedder
Comment options

Comment options

You must be logged in to vote
1 reply
@bikeshedder
Comment options

Comment options

You must be logged in to vote
8 replies
@bikeshedder
Comment options

@bikeshedder
Comment options

@bikeshedder
Comment options

@tibbe
Comment options

@bikeshedder
Comment options

Answer selected by bikeshedder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants