Environment variables at runtime to connect to database
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
use secrecy::ExposeSecret;
|
||||
use sqlx::PgPool;
|
||||
use sqlx::postgres::PgPoolOptions;
|
||||
use tokio::net::TcpListener;
|
||||
use zero2prod::{configuration::get_configuration, startup::run, telemetry::init_subscriber};
|
||||
|
||||
@@ -14,8 +13,7 @@ async fn main() {
|
||||
.await
|
||||
.unwrap();
|
||||
tracing::debug!("listening on {}", listener.local_addr().unwrap());
|
||||
let connection_pool =
|
||||
PgPool::connect_lazy(configuration.database.connection_string().expose_secret()).unwrap();
|
||||
let connection_pool = PgPoolOptions::new().connect_lazy_with(configuration.database.with_db());
|
||||
|
||||
run(listener, connection_pool).await
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user