mirror of
https://github.com/launchbadge/sqlx
synced 2024-11-10 06:24:16 +00:00
Add a get_database
method (#2871)
The Postgres implementation has this method. It is also helpful for queries that require the current datbase name. example: ```sql SELECT table_name FROM INFORMATION_SCHEMA.TABLES WHERE table_name = ? && table_schema = ?; ```
This commit is contained in:
parent
6ecb5831f4
commit
9a6ebd0a74
1 changed files with 14 additions and 0 deletions
|
@ -152,6 +152,20 @@ impl MySqlConnectOptions {
|
|||
self
|
||||
}
|
||||
|
||||
/// Get the current database name.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// # use sqlx_core::mysql::MySqlConnectOptions;
|
||||
/// let options = MySqlConnectOptions::new()
|
||||
/// .database("mysqldb");
|
||||
/// 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.
|
||||
///
|
||||
|
|
Loading…
Reference in a new issue