pub async fn pg_pool() -> Result<Pool<Postgres>, PgExtrasError>Expand description
Creates a new connection pool to PostgreSQL.
Uses either PG_EXTRAS_DATABASE_URL or DATABASE_URL environment variable.
Examples found in repository?
examples/db_settings.rs (line 10)
4async fn main() -> Result<(), PgExtrasError> {
5 std::env::set_var(
6 "PG_EXTRAS_DATABASE_URL",
7 "postgres://postgres:secret@localhost:5432/pg-extras-rs-test",
8 );
9
10 let pool = pg_pool().await?;
11
12 let settings = db_settings(&pool).await?;
13 render_table(settings);
14
15 Ok(())
16}