pub struct SqlxConfig {
pub url: String,
pub backend: DatabaseBackend,
pub max_connections: u32,
pub min_connections: u32,
pub connect_timeout: Duration,
pub idle_timeout: Option<Duration>,
pub max_lifetime: Option<Duration>,
pub statement_cache_capacity: usize,
pub ssl_mode: SslMode,
pub application_name: Option<String>,
}Expand description
SQLx pool configuration.
Fields§
§url: StringDatabase connection URL
backend: DatabaseBackendDatabase backend type (auto-detected from URL)
max_connections: u32Maximum number of connections in the pool
min_connections: u32Minimum number of connections to keep idle
connect_timeout: DurationConnection timeout
idle_timeout: Option<Duration>Idle connection timeout
max_lifetime: Option<Duration>Maximum lifetime of a connection
statement_cache_capacity: usizeEnable statement caching
ssl_mode: SslModeEnable SSL/TLS
application_name: Option<String>Application name (for PostgreSQL)
Implementations§
Source§impl SqlxConfig
impl SqlxConfig
Sourcepub fn from_url(url: impl Into<String>) -> SqlxResult<Self>
pub fn from_url(url: impl Into<String>) -> SqlxResult<Self>
Create a new configuration from a database URL.
§Example
use prax_sqlx::SqlxConfig;
let config = SqlxConfig::from_url("postgres://user:pass@localhost/mydb").unwrap();
assert_eq!(config.max_connections, 10);Sourcepub fn builder(url: impl Into<String>) -> SqlxConfigBuilder
pub fn builder(url: impl Into<String>) -> SqlxConfigBuilder
Create a builder for more detailed configuration.
Sourcepub fn with_max_connections(self, max: u32) -> Self
pub fn with_max_connections(self, max: u32) -> Self
Set max connections.
Sourcepub fn with_min_connections(self, min: u32) -> Self
pub fn with_min_connections(self, min: u32) -> Self
Set min connections.
Sourcepub fn with_connect_timeout(self, timeout: Duration) -> Self
pub fn with_connect_timeout(self, timeout: Duration) -> Self
Set connection timeout.
Sourcepub fn with_idle_timeout(self, timeout: Duration) -> Self
pub fn with_idle_timeout(self, timeout: Duration) -> Self
Set idle timeout.
Sourcepub fn with_max_lifetime(self, lifetime: Duration) -> Self
pub fn with_max_lifetime(self, lifetime: Duration) -> Self
Set max lifetime.
Sourcepub fn with_statement_cache(self, capacity: usize) -> Self
pub fn with_statement_cache(self, capacity: usize) -> Self
Set statement cache capacity.
Sourcepub fn with_ssl_mode(self, mode: SslMode) -> Self
pub fn with_ssl_mode(self, mode: SslMode) -> Self
Set SSL mode.
Sourcepub fn with_application_name(self, name: impl Into<String>) -> Self
pub fn with_application_name(self, name: impl Into<String>) -> Self
Set application name.
Trait Implementations§
Source§impl Clone for SqlxConfig
impl Clone for SqlxConfig
Source§fn clone(&self) -> SqlxConfig
fn clone(&self) -> SqlxConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SqlxConfig
impl Debug for SqlxConfig
Auto Trait Implementations§
impl Freeze for SqlxConfig
impl RefUnwindSafe for SqlxConfig
impl Send for SqlxConfig
impl Sync for SqlxConfig
impl Unpin for SqlxConfig
impl UnwindSafe for SqlxConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more