conninfo - manipulate connection strings - psycopg 3.1.9 documentation
Psycopg - PostgreSQL database adapter for Python - Psycopg documentation
conninfo
- manipulate connection strings
#
This module contains a few utility functions to manipulate database connection strings.
- psycopg.conninfo. conninfo_to_dict ( conninfo = '' , ** kwargs ) #
-
Convert the
conninfo
string into a dictionary of parameters.- Parameters :
-
-
conninfo (
str
) - A connection string as accepted by PostgreSQL. -
kwargs (
Any
) - Parameters overriding the ones specified inconninfo
.
-
- Return type :
- Returns :
-
Dictionary with the parameters parsed from
conninfo
andkwargs
.
Raise
ProgrammingError
ifconninfo
is not a a valid connection string.>>> conninfo_to_dict("postgres://jeff@example.com/db", user="piro") {'user': 'piro', 'dbname': 'db', 'host': 'example.com'}
- psycopg.conninfo. make_conninfo ( conninfo = '' , ** kwargs ) #
-
Merge a string and keyword params into a single conninfo string.
- Parameters :
-
-
conninfo (
str
) - A connection string as accepted by PostgreSQL. -
kwargs (
Any
) - Parameters overriding the ones specified inconninfo
.
-
- Return type :
- Returns :
-
A connection string valid for PostgreSQL, with the
kwargs
parameters merged.
Raise
ProgrammingError
if the input doesn’t make a valid conninfo string.>>> make_conninfo("dbname=db user=jeff", user="piro", port=5432) 'dbname=db user=piro port=5432'