langchain-ai / langchain-postgres

LangChain abstractions backed by Postgres Backend
MIT License
134 stars 48 forks source link

Implementation Suggestion: for creating connection string from db params method #41

Open manoj9896 opened 6 months ago

manoj9896 commented 6 months ago

This is the current implementation for this method def connection_string_from_db_params( cls, driver: str, host: str, port: int, database: str, user: str, password: str, ) -> str: """Return connection string from database parameters.""" if driver != "psycopg": raise NotImplementedError("Only psycopg3 driver is supported") return f"postgresql+{driver}://{user}:{password}@{host}:{port}/{database}"

But the above implementation in not handling the password properly i.e. if password contains the special characters they are not converted to there corresponding ascii value

Suggestion: we can use from sqlalchemy import URL connection_string = URL.create( drivername="", database="", username="", password="", host="", port=, )