pub struct DB { /* private fields */ }Expand description
Responsible for working with postgresql database:
Properties
client: Option<tokio_postgres::Client>- Client for connection to database;sql_conn: tokio_postgres::Config- Connection config;tls: Option<MakeTlsConnector>- Use tls for connection when sslmode=require;zone: Option<String>- Time zone to init database;prepare: Vec<DBStatement>- Prepare statement to database.
Implementations§
source§impl DB
impl DB
sourcepub async fn new(config: Arc<DBConfig>) -> DB
pub async fn new(config: Arc<DBConfig>) -> DB
Initializes a new object DB
Parameters
config: Arc<DBConfig>- database configuration.
Return
DB- new DB object
sourcepub async fn connect(&mut self) -> bool
pub async fn connect(&mut self) -> bool
Connect to the database
Return
true- the connection was successful;false- the connection was fail.
sourcepub async fn query_params(
&mut self,
query: &str,
params: &[&(dyn ToSql + Sync)]
) -> Option<Vec<Row>>
pub async fn query_params( &mut self, query: &str, params: &[&(dyn ToSql + Sync)] ) -> Option<Vec<Row>>
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for DB
impl Send for DB
impl Sync for DB
impl Unpin 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