···11+# neon database configuration
22+33+configuration guide for connecting to neon postgres databases.
44+55+## overview
66+77+plyr.fm uses [neon](https://neon.tech) for all database environments (dev, staging, prod). neon uses a specialized proxy architecture that requires specific connection settings for security and reliability.
88+99+## connection string format
1010+1111+the connection string must use the **psycopg** driver and include specific ssl parameters.
1212+1313+### format
1414+```bash
1515+postgresql+psycopg://<user>:<password>@<host>/<dbname>?sslmode=require&channel_binding=require
1616+```
1717+1818+### key components
1919+2020+1. **driver**: `postgresql+psycopg://`
2121+ - **required**: we must use the `psycopg` (v3) driver, not `asyncpg`.
2222+ - **reason**: `asyncpg` does not support the `channel_binding` parameter, which is required for strict ssl verification with neon.
2323+2424+2. **ssl mode**: `sslmode=require`
2525+ - forces ssl encryption for the connection.
2626+2727+3. **channel binding**: `channel_binding=require`
2828+ - ensures the connection is not intercepted (mitm protection).
2929+ - uses SCRAM-SHA-256-PLUS authentication.
3030+3131+## environment variables
3232+3333+set the `DATABASE_URL` in your `.env` file:
3434+3535+```bash
3636+# development (example)
3737+DATABASE_URL=postgresql+psycopg://<user>:<password>@<host>/<dbname>?sslmode=require&channel_binding=require
3838+```
3939+4040+## troubleshooting
4141+4242+### typeerror: connect() got an unexpected keyword argument 'channel_binding'
4343+4444+**cause**: using `postgresql+asyncpg://` with `channel_binding=require`.
4545+**fix**: change the scheme to `postgresql+psycopg://`.
4646+4747+### connection refused / ssl errors
4848+4949+**cause**: missing `sslmode=require` or `channel_binding=require`.
5050+**fix**: ensure both parameters are present in the query string.
5151+5252+## references
5353+5454+- [neon documentation](https://neon.tech/docs)
5555+- [sqlalchemy psycopg dialect](https://docs.sqlalchemy.org/en/20/dialects/postgresql.html#module-sqlalchemy.dialects.postgresql.psycopg)