pub enum Database {
Postgres(Arc<Pool<Postgres>>),
Sqlite(Arc<Pool<Sqlite>>),
}Expand description
Variants§
Implementations§
Source§impl Database
impl Database
Sourcepub async fn postgres(database_url: &str) -> Result<Self, Error>
pub async fn postgres(database_url: &str) -> Result<Self, Error>
Connect to a PostgreSQL database
Sourcepub async fn ping_pg(&self) -> Result<(), Error>
pub async fn ping_pg(&self) -> Result<(), Error>
Check whether the selected database pool is reachable.
Sourcepub async fn ping_sqlite(&self) -> Result<(), Error>
pub async fn ping_sqlite(&self) -> Result<(), Error>
Check whether the selected database pool is reachable.
Sourcepub async fn begin_pg(&self) -> Result<Transaction<'_, Postgres>, Error>
pub async fn begin_pg(&self) -> Result<Transaction<'_, Postgres>, Error>
Begin a PostgreSQL transaction for explicit commit/rollback control.
Sourcepub async fn begin_sqlite(&self) -> Result<Transaction<'_, Sqlite>, Error>
pub async fn begin_sqlite(&self) -> Result<Transaction<'_, Sqlite>, Error>
Begin a SQLite transaction for explicit commit/rollback control.
Sourcepub async fn execute_pg(&self, query: &str) -> Result<u64, Error>
pub async fn execute_pg(&self, query: &str) -> Result<u64, Error>
Execute a raw SQL query and return affected rows.
pub async fn execute_sqlite(&self, query: &str) -> Result<u64, Error>
Sourcepub fn sqlite_pool(&self) -> Option<&Pool<Sqlite>>
pub fn sqlite_pool(&self) -> Option<&Pool<Sqlite>>
Get the underlying SQLite pool
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Database
impl !UnwindSafe for Database
impl Freeze for Database
impl Send for Database
impl Sync for Database
impl Unpin for Database
impl UnsafeUnpin for Database
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more