use option version

This commit is contained in:
2021-08-19 21:49:29 -05:00
parent fe01037749
commit c9ddbc70bd
4 changed files with 49 additions and 12 deletions

View File

@@ -1,11 +1,22 @@
use log::info;
use sqlx::postgres::PgPoolOptions;
use sqlx::postgres::{
PgConnectOptions,
PgPoolOptions,
};
pub async fn check_postgres() -> Result<(), sqlx::Error> {
// "postgres://demo_user:demo_pass@localhost:8087/demo"
let options = PgConnectOptions::new()
.host("localhost")
.port(8087)
.database("demo")
.username("demo_user")
.password("demo_pass");
let pool = PgPoolOptions::new()
.max_connections(5)
.connect("postgres://demo_user:demo_pass@localhost:8087/demo")
.connect_with(options)
.await?;
// Make a simple query to return the given parameter