pub struct DbReadConnection(/* private fields */);Expand description
Read pool. Multi-connection; concurrent reads enabled by WAL mode.
ConnectionTrait is implemented so SELECTs work transparently. Writes
also technically execute (sea-orm has no read-only enforcement at the
trait level), but doing so via this type defeats the purpose — write
paths must take a DbWriteConnection argument.
Clone is cheap: the inner DatabaseConnection holds an Arc over
the underlying sqlx pool, so clones share connection state.
Implementations§
Source§impl DbReadConnection
impl DbReadConnection
Sourcepub fn new(inner: DatabaseConnection) -> Self
pub fn new(inner: DatabaseConnection) -> Self
Wrap a sea-orm connection as a read pool.
Sourcepub async fn open(
db_path: &Path,
max_connections: u32,
connect_timeout: Duration,
busy_timeout: Duration,
) -> Result<Self, Error>
pub async fn open( db_path: &Path, max_connections: u32, connect_timeout: Duration, busy_timeout: Duration, ) -> Result<Self, Error>
Open a stand-alone read pool at db_path with shared PRAGMAs.
Read-only: opening a non-existent DB fails rather than creating it, so a
read consumer never authors or pre-empts the catalog owned by msb.
Sourcepub async fn open_read_only(
db_path: &Path,
connect_timeout: Duration,
busy_timeout: Duration,
) -> Result<Self, Error>
pub async fn open_read_only( db_path: &Path, connect_timeout: Duration, busy_timeout: Duration, ) -> Result<Self, Error>
Open an existing catalog without creating it or changing its journal mode.
Intended for short control lookups after the caller coordinates with migrations. This is a normal WAL-aware reader, never an immutable-file shortcut.
Sourcepub fn inner(&self) -> &DatabaseConnection
pub fn inner(&self) -> &DatabaseConnection
Borrow the underlying sea-orm connection.
Trait Implementations§
Source§impl Clone for DbReadConnection
impl Clone for DbReadConnection
Source§fn clone(&self) -> DbReadConnection
fn clone(&self) -> DbReadConnection
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl ConnectionTrait for DbReadConnection
impl ConnectionTrait for DbReadConnection
Source§fn get_database_backend(&self) -> DbBackend
fn get_database_backend(&self) -> DbBackend
Source§fn execute_raw<'life0, 'async_trait>(
&'life0 self,
stmt: Statement,
) -> Pin<Box<dyn Future<Output = Result<ExecResult, DbErr>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn execute_raw<'life0, 'async_trait>(
&'life0 self,
stmt: Statement,
) -> Pin<Box<dyn Future<Output = Result<ExecResult, DbErr>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn execute_unprepared<'life0, 'life1, 'async_trait>(
&'life0 self,
sql: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<ExecResult, DbErr>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn execute_unprepared<'life0, 'life1, 'async_trait>(
&'life0 self,
sql: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<ExecResult, DbErr>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn query_one_raw<'life0, 'async_trait>(
&'life0 self,
stmt: Statement,
) -> Pin<Box<dyn Future<Output = Result<Option<QueryResult>, DbErr>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn query_one_raw<'life0, 'async_trait>(
&'life0 self,
stmt: Statement,
) -> Pin<Box<dyn Future<Output = Result<Option<QueryResult>, DbErr>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
QueryResultSource§fn query_all_raw<'life0, 'async_trait>(
&'life0 self,
stmt: Statement,
) -> Pin<Box<dyn Future<Output = Result<Vec<QueryResult>, DbErr>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn query_all_raw<'life0, 'async_trait>(
&'life0 self,
stmt: Statement,
) -> Pin<Box<dyn Future<Output = Result<Vec<QueryResult>, DbErr>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
QueryResultSource§fn support_returning(&self) -> bool
fn support_returning(&self) -> bool
RETURNING syntax on insert and updateSource§fn is_mock_connection(&self) -> bool
fn is_mock_connection(&self) -> bool
Source§fn execute<'life0, 'life1, 'async_trait, S>(
&'life0 self,
stmt: &'life1 S,
) -> Pin<Box<dyn Future<Output = Result<ExecResult, DbErr>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
S: 'async_trait + StatementBuilder,
Self: 'async_trait,
fn execute<'life0, 'life1, 'async_trait, S>(
&'life0 self,
stmt: &'life1 S,
) -> Pin<Box<dyn Future<Output = Result<ExecResult, DbErr>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
S: 'async_trait + StatementBuilder,
Self: 'async_trait,
StatementBuilderSource§fn query_one<'life0, 'life1, 'async_trait, S>(
&'life0 self,
stmt: &'life1 S,
) -> Pin<Box<dyn Future<Output = Result<Option<QueryResult>, DbErr>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
S: 'async_trait + StatementBuilder,
Self: 'async_trait,
fn query_one<'life0, 'life1, 'async_trait, S>(
&'life0 self,
stmt: &'life1 S,
) -> Pin<Box<dyn Future<Output = Result<Option<QueryResult>, DbErr>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
S: 'async_trait + StatementBuilder,
Self: 'async_trait,
StatementBuilder and return a single row of QueryResultSource§fn query_all<'life0, 'life1, 'async_trait, S>(
&'life0 self,
stmt: &'life1 S,
) -> Pin<Box<dyn Future<Output = Result<Vec<QueryResult>, DbErr>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
S: 'async_trait + StatementBuilder,
Self: 'async_trait,
fn query_all<'life0, 'life1, 'async_trait, S>(
&'life0 self,
stmt: &'life1 S,
) -> Pin<Box<dyn Future<Output = Result<Vec<QueryResult>, DbErr>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
S: 'async_trait + StatementBuilder,
Self: 'async_trait,
StatementBuilder and return a vector of QueryResultAuto Trait Implementations§
impl !RefUnwindSafe for DbReadConnection
impl !UnwindSafe for DbReadConnection
impl Freeze for DbReadConnection
impl Send for DbReadConnection
impl Sync for DbReadConnection
impl Unpin for DbReadConnection
impl UnsafeUnpin for DbReadConnection
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
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> ⓘ
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> ⓘ
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