diff --git a/sqlx-core/src/pool/mod.rs b/sqlx-core/src/pool/mod.rs index 6ca6739144..34554e23dc 100644 --- a/sqlx-core/src/pool/mod.rs +++ b/sqlx-core/src/pool/mod.rs @@ -435,6 +435,11 @@ impl Pool { pub fn num_idle(&self) -> usize { self.0.num_idle() } + + /// Get the connection options for this pool + pub fn connect_options(&self) -> &::Options { + &self.0.connect_options + } } #[cfg(all( diff --git a/sqlx-core/src/postgres/options/mod.rs b/sqlx-core/src/postgres/options/mod.rs index 638629b6cf..bedeb6bda1 100644 --- a/sqlx-core/src/postgres/options/mod.rs +++ b/sqlx-core/src/postgres/options/mod.rs @@ -260,6 +260,20 @@ impl PgConnectOptions { self } + /// Get the current database name. + /// + /// # Example + /// + /// ```rust + /// # use sqlx_core::postgres::PgConnectOptions; + /// let options = PgConnectOptions::new() + /// .database("postgres"); + /// assert!(options.get_database().is_some()); + /// ``` + pub fn get_database(&self) -> Option<&str> { + self.database.as_deref() + } + /// Sets whether or with what priority a secure SSL TCP/IP connection will be negotiated /// with the server. ///