pub struct Db { /* private fields */ }Expand description
A database connection pool that auto-selects the backend based on the connection URL scheme.
Db is cheap to clone (internally reference-counted) and safe to share
across tokio tasks.
Implementations§
Source§impl Db
impl Db
Sourcepub async fn connect(url: &str) -> Result<Self, FlozError>
pub async fn connect(url: &str) -> Result<Self, FlozError>
Connect to a database, auto-detecting the backend from the URL scheme.
postgres://...orpostgresql://...→ PostgreSQLsqlite://...orsqlite::memory:→ SQLite
Trait Implementations§
Source§impl Executor for Db
impl Executor for Db
Source§async fn execute_raw(
&self,
sql: &str,
params: Vec<Value>,
) -> Result<u64, FlozError>
async fn execute_raw( &self, sql: &str, params: Vec<Value>, ) -> Result<u64, FlozError>
Execute a raw SQL statement, returning the number of affected rows.
Source§async fn fetch_all<T>(
&self,
sql: &str,
params: Vec<Value>,
) -> Result<Vec<T>, FlozError>
async fn fetch_all<T>( &self, sql: &str, params: Vec<Value>, ) -> Result<Vec<T>, FlozError>
Fetch all matching rows.
Auto Trait Implementations§
impl Freeze for Db
impl RefUnwindSafe for Db
impl Send for Db
impl Sync for Db
impl Unpin for Db
impl UnsafeUnpin for Db
impl UnwindSafe for Db
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,
impl<T> FlozRowBound for T
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