langchain-postgres icon indicating copy to clipboard operation
langchain-postgres copied to clipboard

Implementation Suggestion: for creating connection string from db params method

Open manoj9896 opened this issue 9 months ago • 0 comments

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=, )

manoj9896 avatar May 07 '24 05:05 manoj9896