Skip to content

Connection

deep_db_agents.connection

Connection configuration passed to dialects.

ConnectionConfig dataclass

ConnectionConfig(scheme: str, host: str | None, port: int | None, credential: dict[str, Any] = dict(), path: str | None = None)

Connection parameters for a database.

credential is a free-form dictionary whose content depends on the specific DB (e.g. {"user": ..., "password": ...} or {"secret_key": ...}). Well-known keys (database/db) are exposed as convenience properties.

Attributes:

Name Type Description
scheme str

The URL scheme identifying the dialect (e.g. "postgres").

host str | None

Hostname for network databases, or None for file-based databases.

port int | None

Port for network databases, or None for file-based databases.

credential dict[str, Any]

Free-form credential/connection dictionary.

path str | None

File/directory path for file-based databases (sqlite/duckdb); None for network databases. :memory: denotes an in-memory database.

database property

database: str | None

Return the logical database/schema name, if provided in the credentials.

Returns:

Type Description
str | None

str | None: The value of the database or db credential key, or

str | None

None if neither is present.

__repr__

__repr__() -> str

Return a repr with credentials masked.

Returns:

Name Type Description
str str

A string representation of this config where credential content

str

is masked so passwords never leak into logs, tracebacks, or error messages.

Source code in src/deep_db_agents/connection.py
44
45
46
47
48
49
50
51
52
53
54
55
56
57
def __repr__(self) -> str:
    """Return a repr with credentials masked.

    Returns:
        str: A string representation of this config where ``credential`` content
        is masked so passwords never leak into logs, tracebacks, or error messages.
    """
    # Mask the contents of ``credential`` so passwords never end up in logs,
    # tracebacks, or error messages when the object is printed.
    cred = "{…}" if self.credential else "{}"
    return (
        f"ConnectionConfig(scheme={self.scheme!r}, host={self.host!r}, "
        f"port={self.port!r}, credential={cred}, path={self.path!r})"
    )