pub struct DbPool { /* private fields */ }Expand description
A highly optimized, easily clonable Database Pool wrapper.
Implementations§
Source§impl DbPool
impl DbPool
Sourcepub fn new(database_url: &str, max_connections: usize) -> Result<Self, DbError>
pub fn new(database_url: &str, max_connections: usize) -> Result<Self, DbError>
Create a new PostgreSQL connection pool without panicking.
Takes &str to avoid unnecessary allocations and allows configuring max_size.
Sourcepub async fn execute(
&self,
query: &str,
params: &[&(dyn ToSql + Sync)],
) -> Result<u64, DbError>
pub async fn execute( &self, query: &str, params: &[&(dyn ToSql + Sync)], ) -> Result<u64, DbError>
Execute INSERT / UPDATE / DELETE Returns affected rows
Sourcepub async fn query_one(
&self,
query: &str,
params: &[&(dyn ToSql + Sync)],
) -> Result<Row, DbError>
pub async fn query_one( &self, query: &str, params: &[&(dyn ToSql + Sync)], ) -> Result<Row, DbError>
Get ONE row
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for DbPool
impl !UnwindSafe for DbPool
impl Freeze for DbPool
impl Send for DbPool
impl Sync for DbPool
impl Unpin for DbPool
impl UnsafeUnpin for DbPool
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