Struct sea_orm::ConnectOptions
source · pub struct ConnectOptions { /* private fields */ }
Expand description
Defines the configuration options of a database
Implementations§
source§impl ConnectOptions
impl ConnectOptions
sourcepub fn new(url: String) -> Self
pub fn new(url: String) -> Self
Create new ConnectOptions for a Database by passing in a URI string
Examples found in repository?
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
fn from(string: String) -> ConnectOptions {
ConnectOptions::new(string)
}
}
impl ConnectOptions {
/// Create new [ConnectOptions] for a [Database] by passing in a URI string
pub fn new(url: String) -> Self {
Self {
url,
max_connections: None,
min_connections: None,
connect_timeout: None,
idle_timeout: None,
acquire_timeout: None,
max_lifetime: None,
sqlx_logging: true,
sqlx_logging_level: log::LevelFilter::Info,
sqlcipher_key: None,
schema_search_path: None,
}
}
fn from_str(url: &str) -> Self {
Self::new(url.to_owned())
}
sourcepub fn pool_options<DB>(self) -> PoolOptions<DB>where
DB: Database,
pub fn pool_options<DB>(self) -> PoolOptions<DB>where
DB: Database,
Convert ConnectOptions into [sqlx::pool::PoolOptions]
sourcepub fn max_connections(&mut self, value: u32) -> &mut Self
pub fn max_connections(&mut self, value: u32) -> &mut Self
Set the maximum number of connections of the pool
sourcepub fn get_max_connections(&self) -> Option<u32>
pub fn get_max_connections(&self) -> Option<u32>
Get the maximum number of connections of the pool, if set
sourcepub fn min_connections(&mut self, value: u32) -> &mut Self
pub fn min_connections(&mut self, value: u32) -> &mut Self
Set the minimum number of connections of the pool
sourcepub fn get_min_connections(&self) -> Option<u32>
pub fn get_min_connections(&self) -> Option<u32>
Get the minimum number of connections of the pool, if set
sourcepub fn connect_timeout(&mut self, value: Duration) -> &mut Self
pub fn connect_timeout(&mut self, value: Duration) -> &mut Self
Set the timeout duration when acquiring a connection
sourcepub fn get_connect_timeout(&self) -> Option<Duration>
pub fn get_connect_timeout(&self) -> Option<Duration>
Get the timeout duration when acquiring a connection, if set
sourcepub fn idle_timeout(&mut self, value: Duration) -> &mut Self
pub fn idle_timeout(&mut self, value: Duration) -> &mut Self
Set the idle duration before closing a connection
sourcepub fn get_idle_timeout(&self) -> Option<Duration>
pub fn get_idle_timeout(&self) -> Option<Duration>
Get the idle duration before closing a connection, if set
sourcepub fn acquire_timeout(&mut self, value: Duration) -> &mut Self
pub fn acquire_timeout(&mut self, value: Duration) -> &mut Self
Set the maximum amount of time to spend waiting for acquiring a connection
sourcepub fn get_acquire_timeout(&self) -> Option<Duration>
pub fn get_acquire_timeout(&self) -> Option<Duration>
Get the maximum amount of time to spend waiting for acquiring a connection
sourcepub fn max_lifetime(&mut self, lifetime: Duration) -> &mut Self
pub fn max_lifetime(&mut self, lifetime: Duration) -> &mut Self
Set the maximum lifetime of individual connections
sourcepub fn get_max_lifetime(&self) -> Option<Duration>
pub fn get_max_lifetime(&self) -> Option<Duration>
Get the maximum lifetime of individual connections, if set
sourcepub fn sqlx_logging(&mut self, value: bool) -> &mut Self
pub fn sqlx_logging(&mut self, value: bool) -> &mut Self
Enable SQLx statement logging (default true)
sourcepub fn get_sqlx_logging(&self) -> bool
pub fn get_sqlx_logging(&self) -> bool
Get whether SQLx statement logging is enabled
sourcepub fn sqlx_logging_level(&mut self, level: LevelFilter) -> &mut Self
pub fn sqlx_logging_level(&mut self, level: LevelFilter) -> &mut Self
Set SQLx statement logging level (default INFO)
(ignored if sqlx_logging
is false
)
sourcepub fn get_sqlx_logging_level(&self) -> LevelFilter
pub fn get_sqlx_logging_level(&self) -> LevelFilter
Get the level of SQLx statement logging
sourcepub fn sqlcipher_key<T>(&mut self, value: T) -> &mut Selfwhere
T: Into<Cow<'static, str>>,
pub fn sqlcipher_key<T>(&mut self, value: T) -> &mut Selfwhere
T: Into<Cow<'static, str>>,
set key for sqlcipher
sourcepub fn set_schema_search_path(&mut self, schema_search_path: String) -> &mut Self
pub fn set_schema_search_path(&mut self, schema_search_path: String) -> &mut Self
Set schema search path (PostgreSQL only)
Trait Implementations§
source§impl Clone for ConnectOptions
impl Clone for ConnectOptions
source§fn clone(&self) -> ConnectOptions
fn clone(&self) -> ConnectOptions
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more