pub struct PgConnection { /* private fields */ }Expand description
A wrapper around a PostgreSQL connection with statement caching.
Implementations§
Source§impl PgConnection
impl PgConnection
Sourcepub async fn query(
&self,
sql: &str,
params: &[&(dyn ToSql + Sync)],
) -> PgResult<Vec<Row>>
pub async fn query( &self, sql: &str, params: &[&(dyn ToSql + Sync)], ) -> PgResult<Vec<Row>>
Execute a query and return all rows.
Sourcepub async fn query_one(
&self,
sql: &str,
params: &[&(dyn ToSql + Sync)],
) -> PgResult<Row>
pub async fn query_one( &self, sql: &str, params: &[&(dyn ToSql + Sync)], ) -> PgResult<Row>
Execute a query and return exactly one row.
Sourcepub async fn query_opt(
&self,
sql: &str,
params: &[&(dyn ToSql + Sync)],
) -> PgResult<Option<Row>>
pub async fn query_opt( &self, sql: &str, params: &[&(dyn ToSql + Sync)], ) -> PgResult<Option<Row>>
Execute a query and return zero or one row.
Sourcepub async fn execute(
&self,
sql: &str,
params: &[&(dyn ToSql + Sync)],
) -> PgResult<u64>
pub async fn execute( &self, sql: &str, params: &[&(dyn ToSql + Sync)], ) -> PgResult<u64>
Execute a statement and return the number of affected rows.
Sourcepub async fn batch_execute(&self, sql: &str) -> PgResult<()>
pub async fn batch_execute(&self, sql: &str) -> PgResult<()>
Execute a batch of statements in a single round-trip.
Sourcepub async fn transaction(&mut self) -> PgResult<PgTransaction<'_>>
pub async fn transaction(&mut self) -> PgResult<PgTransaction<'_>>
Begin a transaction.
Sourcepub fn inner(&self) -> &Object
pub fn inner(&self) -> &Object
Get the underlying tokio-postgres client.
This is useful for advanced operations not covered by this wrapper.
Sourcepub async fn query_cached(
&self,
sql: &str,
params: &[&(dyn ToSql + Sync)],
) -> PgResult<Vec<Row>>
pub async fn query_cached( &self, sql: &str, params: &[&(dyn ToSql + Sync)], ) -> PgResult<Vec<Row>>
Execute a query using the prepared statement cache.
This is an alias for query that makes it explicit that statement caching
is being used. All query methods already use prepared statement caching,
but this method name makes it more explicit for benchmark comparisons.
Auto Trait Implementations§
impl Freeze for PgConnection
impl !RefUnwindSafe for PgConnection
impl Send for PgConnection
impl Sync for PgConnection
impl Unpin for PgConnection
impl !UnwindSafe for PgConnection
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