> ## Documentation Index
> Fetch the complete documentation index at: https://oxy.tech/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Postgres

This guide explains how to connect to PostgreSQL with Oxygen. PostgreSQL is a powerful, open-source object-relational database system.

## Configuration Options

Add your PostgreSQL configuration to `config.yml`. Here are all available parameters:

```yaml theme={null}
databases:
  - name: my_postgres_db # Unique identifier for this connection
    type: postgres
    host: "localhost" # PostgreSQL server hostname or IP
    port: 5432 # PostgreSQL server port (default: 5432)
    user: "postgres" # Username for authentication
    password: <password> # Direct password (not recommended)
    password_var: "PG_PWD" # Environment variable containing password (recommended)
    database: "postgres" # Database name to connect to
    ssl_mode: "require" # SSL mode (disable, require, verify-ca, verify-full)
```

## Example Configurations

<Steps>
  <Step title="Prepare password environment variable">
    Export the environment variable:

    ```sh theme={null}
    export PG_PWD=<your password>
    ```

    Or put it in `.env` file:

    ```sh theme={null}
    echo PG_PWD=<your password> >> .env
    ```
  </Step>

  <Step title="Add PostgreSQL configuration">
    ```yaml theme={null}
    databases:
      - name: local_pg
        type: postgres
        host: "localhost"
        port: 5432
        user: "postgres"
        password_var: "PG_PWD"
        database: "myapp"
        ssl_mode: "disable"
    ```
  </Step>
</Steps>

## Troubleshooting

* Test connection: `psql -h localhost -U postgres -d mydb`
* Check server logs: `/var/log/postgresql/postgresql-*.log`
* Common issues:
  * Wrong credentials
  * Incorrect `pg_hba.conf` configuration
  * Network/firewall restrictions
  * SSL certificate problems
* Monitor performance: Use `pg_stat_*` views
