diesel::pg

Struct PgConnection

Source
pub struct PgConnection { /* private fields */ }
Expand description

The connection string expected by PgConnection::establish should be a PostgreSQL connection string, as documented at https://www.postgresql.org/docs/9.4/static/libpq-connect.html#LIBPQ-CONNSTRING

Implementations§

Source§

impl PgConnection

Source

pub fn build_transaction(&self) -> TransactionBuilder<'_>

Build a transaction, specifying additional details such as isolation level

See TransactionBuilder for more examples.

conn.build_transaction()
    .read_only()
    .serializable()
    .deferrable()
    .run(|| Ok(()))

Trait Implementations§

Source§

impl Connection for PgConnection

Source§

type Backend = Pg

The backend this type connects to
Source§

fn establish(database_url: &str) -> ConnectionResult<PgConnection>

Establishes a new connection to the database Read more
Source§

fn transaction<T, E, F>(&self, f: F) -> Result<T, E>
where F: FnOnce() -> Result<T, E>, E: From<Error>,

Executes the given function inside of a database transaction Read more
Source§

fn begin_test_transaction(&self) -> QueryResult<()>

Creates a transaction that will never be committed. This is useful for tests. Panics if called while inside of a transaction.
Source§

fn test_transaction<T, E, F>(&self, f: F) -> T
where F: FnOnce() -> Result<T, E>, E: Debug,

Executes the given function inside a transaction, but does not commit it. Panics if the given function returns an error. Read more
Source§

impl SimpleConnection for PgConnection

Source§

fn batch_execute(&self, query: &str) -> QueryResult<()>

Execute multiple SQL statements within the same string. Read more
Source§

impl<Changes, Output> UpdateAndFetchResults<Changes, Output> for PgConnection
where Changes: Copy + AsChangeset<Target = <Changes as HasTable>::Table> + IntoUpdateTarget, Update<Changes, Changes>: LoadQuery<PgConnection, Output>,

Source§

fn update_and_fetch(&self, changeset: Changes) -> QueryResult<Output>

See the traits documentation.
Source§

impl Send for PgConnection

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoSql for T

Source§

fn into_sql<T>(self) -> AsExprOf<Self, T>
where Self: AsExpression<T> + Sized,

Convert self to an expression for Diesel’s query builder. Read more
Source§

fn as_sql<'a, T>(&'a self) -> AsExprOf<&'a Self, T>
where &'a Self: AsExpression<T>,

Convert &self to an expression for Diesel’s query builder. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.