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

Open
opened 2026-02-16 05:16:03 -05:00 by yindo · 0 comments
Owner

Originally created by @manoj9896 on GitHub (May 7, 2024).

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

Originally created by @manoj9896 on GitHub (May 7, 2024). 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=, ) `
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langchain-postgres#10