[−][src]Trait rbatis_core::connection::Connection
Represents a single database connection rather than a pool of database connections.
Connections can be manually established outside of a Pool with Connect::connect.
Prefer running queries from Pool unless there is a specific need for a single, sticky
connection.
Required methods
fn close(self) -> BoxFuture<'static, Result<()>>
Explicitly close this database connection.
This method is not required for safe and consistent operation. However, it is
recommended to call it instead of letting a connection drop as the database server
will be faster at cleaning up resources.
fn ping(&mut self) -> BoxFuture<'_, Result<()>>
Checks if a connection to the database is still valid.
Provided methods
fn begin(self) -> BoxFuture<'static, Result<Transaction<Self>>> where
Self: Sized,
Self: Sized,
Starts a new transaction. 从conn启动一个事务,因为conn的所有权移动给了Transaction,直到Transaction commit 或者 rollback完成时返回原来的conn连接
Wraps this connection in Transaction to manage the transaction lifecycle. To get the
original connection back, explicitly commit or rollback and this connection will
be returned.
let mut tx = conn.begin().await?; // conn is now inaccessible as its wrapped in a transaction let conn = tx.commit().await?; // conn is back now and out of the transaction
Implementors
impl Connection for MySqlConnection[src]
fn close(self) -> BoxFuture<'static, Result<()>>[src]
fn ping(&mut self) -> BoxFuture<'_, Result<()>>[src]
impl Connection for PgConnection[src]
fn close(self) -> BoxFuture<'static, Result<()>>[src]
fn ping(&mut self) -> BoxFuture<'_, Result<()>>[src]
impl Connection for SqliteConnection[src]
fn close(self) -> BoxFuture<'static, Result<()>>[src]
fn ping(&mut self) -> BoxFuture<'_, Result<()>>[src]
impl<C> Connection for PoolConnection<C> where
C: Connect, [src]
C: Connect,
fn close(self) -> BoxFuture<'static, Result<()>>[src]
fn ping(&mut self) -> BoxFuture<'_, Result<()>>[src]
impl<C> Connection for Transaction<C> where
C: Connection, [src]
C: Connection,