[−][src]Trait sqlx_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.
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<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,