Struct diesel::pg::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
sourceimpl PgConnection
impl PgConnection
sourcepub fn build_transaction(&self) -> TransactionBuilder<'_>
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
sourceimpl Connection for PgConnection
impl Connection for PgConnection
sourcefn establish(database_url: &str) -> ConnectionResult<PgConnection>
fn establish(database_url: &str) -> ConnectionResult<PgConnection>
Establishes a new connection to the database Read more
sourcefn transaction<T, E, F>(&self, f: F) -> Result<T, E> where
F: FnOnce() -> Result<T, E>,
E: From<Error>,
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
sourcefn begin_test_transaction(&self) -> QueryResult<()>
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. Read more
sourceimpl SimpleConnection for PgConnection
impl SimpleConnection for PgConnection
sourcefn batch_execute(&self, query: &str) -> QueryResult<()>
fn batch_execute(&self, query: &str) -> QueryResult<()>
Execute multiple SQL statements within the same string. Read more
sourceimpl<Changes, Output> UpdateAndFetchResults<Changes, Output> for PgConnection where
Changes: Copy + AsChangeset<Target = <Changes as HasTable>::Table> + IntoUpdateTarget,
Update<Changes, Changes>: LoadQuery<PgConnection, Output>,
impl<Changes, Output> UpdateAndFetchResults<Changes, Output> for PgConnection where
Changes: Copy + AsChangeset<Target = <Changes as HasTable>::Table> + IntoUpdateTarget,
Update<Changes, Changes>: LoadQuery<PgConnection, Output>,
sourcefn update_and_fetch(&self, changeset: Changes) -> QueryResult<Output>
fn update_and_fetch(&self, changeset: Changes) -> QueryResult<Output>
See the traits documentation.
impl Send for PgConnection
Auto Trait Implementations
impl !RefUnwindSafe for PgConnection
impl !Sync for PgConnection
impl Unpin for PgConnection
impl UnwindSafe for PgConnection
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more