Extensions
Connecting
Named secrets can be used to manage connections to multiple Postgres database instances. Secrets can be given a name upon creation.  
```sql
CREATE SECRET postgres_secret_one (
TYPE POSTGRES,
HOST '127.0.0.1',
PORT 5432,
DATABASE postgres,
USER 'postgres',
PASSWORD ''
);
```  
The secret can then be explicitly referenced using the `SECRET` parameter in the `ATTACH`.  
```sql
ATTACH '' AS postgres_db_one (TYPE POSTGRES, SECRET postgres_secret_one);
```  
#### Configuring via Environment Variables {#docs:extensions:postgres::configuring-via-environment-variables}  
PostgreSQL connection information can also be specified with [environment variables](https://www.postgresql.org/docs/current/libpq-envars.html).
This can be useful in a production environment where the connection information is managed externally
and passed in to the environment.  
```bash
export PGPASSWORD="secret"
export PGHOST=localhost
export PGUSER=owner
export PGDATABASE=mydatabase
```  
Then, to connect, start the `duckdb` process and run:  
```sql
ATTACH '' AS p (TYPE POSTGRES);
```