Struct rssql::PostgreSQL
source · pub struct PostgreSQL { /* private fields */ }
Implementations§
source§impl PostgreSQL
impl PostgreSQL
sourcepub async fn connect(url: &str) -> Result<PostgreSQL>
pub async fn connect(url: &str) -> Result<PostgreSQL>
Connect to postgresql database.
use rssql::PostgreSQL;
async fn test_postgresql() {
let url = "postgre://user:password@docker:15432/test";
let mut postgresql = PostgreSQL::connect(url).await.unwrap();
let check = postgresql.check_connection().await;
println!("{}", check);
let rets = postgresql.execute("SELECT * FROM info").await.unwrap();
println!("{}", rets);
postgresql.close().await;
}
Output
true
+----+-------+------------+
| id | name | date |
+----+-------+------------+
| 1 | test2 | 2023-06-11 |
| 2 | test1 | 2023-06-11 |
+----+-------+------------+
sourcepub async fn check_connection(&mut self) -> bool
pub async fn check_connection(&mut self) -> bool
Check if the connection is valid.
Auto Trait Implementations§
impl !RefUnwindSafe for PostgreSQL
impl Send for PostgreSQL
impl Sync for PostgreSQL
impl Unpin for PostgreSQL
impl !UnwindSafe for PostgreSQL
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