Enum sea_orm::DatabaseConnection
source · [−]pub enum DatabaseConnection {
SqlxMySqlPoolConnection(SqlxMySqlPoolConnection),
SqlxPostgresPoolConnection(SqlxPostgresPoolConnection),
SqlxSqlitePoolConnection(SqlxSqlitePoolConnection),
MockDatabaseConnection(Arc<MockDatabaseConnection>),
Disconnected,
}
Expand description
Handle a database connection depending on the backend enabled by the feature flags. This creates a database pool.
Variants
SqlxMySqlPoolConnection(SqlxMySqlPoolConnection)
Create a MYSQL database connection and pool
SqlxPostgresPoolConnection(SqlxPostgresPoolConnection)
Create a PostgreSQL database connection and pool
SqlxSqlitePoolConnection(SqlxSqlitePoolConnection)
Create a SQLite database connection and pool
MockDatabaseConnection(Arc<MockDatabaseConnection>)
Create a Mock database connection useful for testing
Disconnected
The connection to the database has been severed
Implementations
sourceimpl DatabaseConnection
impl DatabaseConnection
sourcepub fn as_mock_connection(&self) -> &MockDatabaseConnection
pub fn as_mock_connection(&self) -> &MockDatabaseConnection
Generate a database connection for testing the Mock database
sourcepub fn into_transaction_log(self) -> Vec<Transaction>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn into_transaction_log(self) -> Vec<Transaction>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Get the transaction log as a collection Vec<crate::Transaction>
Trait Implementations
sourceimpl ConnectionTrait for DatabaseConnection
impl ConnectionTrait for DatabaseConnection
sourcefn get_database_backend(&self) -> DbBackend
fn get_database_backend(&self) -> DbBackend
sourcefn execute<'life0, 'async_trait>(
&'life0 self,
stmt: Statement
) -> Pin<Box<dyn Future<Output = Result<ExecResult, DbErr>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
fn execute<'life0, 'async_trait>(
&'life0 self,
stmt: Statement
) -> Pin<Box<dyn Future<Output = Result<ExecResult, DbErr>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
Execute a Statement
sourcefn query_one<'life0, 'async_trait>(
&'life0 self,
stmt: Statement
) -> Pin<Box<dyn Future<Output = Result<Option<QueryResult>, DbErr>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
fn query_one<'life0, 'async_trait>(
&'life0 self,
stmt: Statement
) -> Pin<Box<dyn Future<Output = Result<Option<QueryResult>, DbErr>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
Execute a Statement and return a query
sourcefn query_all<'life0, 'async_trait>(
&'life0 self,
stmt: Statement
) -> Pin<Box<dyn Future<Output = Result<Vec<QueryResult>, DbErr>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
fn query_all<'life0, 'async_trait>(
&'life0 self,
stmt: Statement
) -> Pin<Box<dyn Future<Output = Result<Vec<QueryResult>, DbErr>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
Execute a Statement and return a collection Vec<QueryResult> on success
sourcefn is_mock_connection(&self) -> bool
fn is_mock_connection(&self) -> bool
Check if the connection is a test connection for the Mock database
sourcefn support_returning(&self) -> bool
fn support_returning(&self) -> bool
Check if the connection supports RETURNING
syntax on insert and update
sourceimpl Debug for DatabaseConnection
impl Debug for DatabaseConnection
sourceimpl Default for DatabaseConnection
impl Default for DatabaseConnection
sourceimpl<'a> StreamTrait<'a> for DatabaseConnection
impl<'a> StreamTrait<'a> for DatabaseConnection
sourceimpl TransactionTrait for DatabaseConnection
impl TransactionTrait for DatabaseConnection
sourcefn transaction<'life0, 'async_trait, F, T, E>(
&'life0 self,
_callback: F
) -> Pin<Box<dyn Future<Output = Result<T, TransactionError<E>>> + Send + 'async_trait>> where
F: for<'c> FnOnce(&'c DatabaseTransaction) -> Pin<Box<dyn Future<Output = Result<T, E>> + Send + 'c>> + Send,
T: Send,
E: Error + Send,
F: 'async_trait,
T: 'async_trait,
E: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
fn transaction<'life0, 'async_trait, F, T, E>(
&'life0 self,
_callback: F
) -> Pin<Box<dyn Future<Output = Result<T, TransactionError<E>>> + Send + 'async_trait>> where
F: for<'c> FnOnce(&'c DatabaseTransaction) -> Pin<Box<dyn Future<Output = Result<T, E>> + Send + 'c>> + Send,
T: Send,
E: Error + Send,
F: 'async_trait,
T: 'async_trait,
E: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
Execute the function inside a transaction. If the function returns an error, the transaction will be rolled back. If it does not return an error, the transaction will be committed.
Auto Trait Implementations
impl !RefUnwindSafe for DatabaseConnection
impl Send for DatabaseConnection
impl Sync for DatabaseConnection
impl Unpin for DatabaseConnection
impl !UnwindSafe for DatabaseConnection
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more