diff --git a/sqlx-core/src/pool/options.rs b/sqlx-core/src/pool/options.rs index a8d5d168..ff12968d 100644 --- a/sqlx-core/src/pool/options.rs +++ b/sqlx-core/src/pool/options.rs @@ -142,6 +142,26 @@ impl PoolOptions { self } + /// Perform an action after connecting to the database. + /// + /// # Example + /// + /// ```no_run + /// # async fn f() -> Result<(), Box> { + /// use sqlx_core::executor::Executor; + /// use sqlx_core::postgres::PgPoolOptions; + /// // PostgreSQL + /// let pool = PgPoolOptions::new() + /// .after_connect(|conn| Box::pin(async move { + /// conn.execute("SET application_name = 'your_app';").await?; + /// conn.execute("SET search_path = 'my_schema';").await?; + /// + /// Ok(()) + /// })) + /// .connect("postgres:// …").await?; + /// # Ok(()) + /// # } + /// ``` pub fn after_connect(mut self, callback: F) -> Self where for<'c> F: