Skip to content

[Feature Request] Support Postgres connection via Unix Socket #152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
langered opened this issue May 16, 2025 · 1 comment
Open

[Feature Request] Support Postgres connection via Unix Socket #152

langered opened this issue May 16, 2025 · 1 comment

Comments

@langered
Copy link

Current Situation:

It is possible to connect a PostgreSQL database via Unix Socket in the SQLAlchemy library:
https://docs.sqlalchemy.org/en/20/dialects/postgresql.html#unix-domain-connections

But it uses a slightly different connection string pattern:

postgres://<user>:<password>@/<database>?host=<db_host>

rag-api is not supporting it because the CONNECTION_STRING is a hard coded pattern which does not support the pattern of the unix socket connection:

rag_api/app/config.py

Lines 71 to 72 in e48968f

CONNECTION_STRING = f"postgresql+psycopg2://{urllib.parse.quote_plus(POSTGRES_USER)}:{urllib.parse.quote_plus(POSTGRES_PASSWORD)}@{DB_HOST}:{DB_PORT}/{urllib.parse.quote_plus(POSTGRES_DB)}"
DSN = f"postgresql://{urllib.parse.quote_plus(POSTGRES_USER)}:{urllib.parse.quote_plus(POSTGRES_PASSWORD)}@{DB_HOST}:{DB_PORT}/{urllib.parse.quote_plus(POSTGRES_DB)}"

This would be beneficial when using the Cloud SQL Postgres:
https://cloud.google.com/sql/docs/postgres/connect-run#connect-unix-socket

Proposal:
Adding a feature flag as environment variable, which enables the connection via unix sockets by modifying the connection string.

@langered
Copy link
Author

I've opened a PR with my proposed changes:

#153

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant