--- /dev/null
+.. _psycopg.conninfo:
+
+`conninfo` -- manipulate connection strings
+===========================================
+
+This module contains a few utility functions to manipulate database
+connection strings.
+
+.. module:: psycopg.conninfo
+
+.. autofunction:: conninfo_to_dict
+
+ .. code:: python
+
+ >>> conninfo_to_dict("postgres://jeff@example.com/db", user="piro")
+ {'user': 'piro', 'dbname': 'db', 'host': 'example.com'}
+
+
+.. autofunction:: make_conninfo
+
+ .. code:: python
+
+ >>> make_conninfo("dbname=db user=jeff", user="piro", port=5432)
+ 'dbname=db user=piro port=5432'
"""
Merge a string and keyword params into a single conninfo string.
- Raise ProgrammingError if the input don't make a valid conninfo.
+ :param conninfo: A `connection string`__ as accepted by PostgreSQL.
+ :param kwargs: Parameters overriding the ones specified in *conninfo*.
+ :return: A connection string valid for PostgreSQL, with the *kwargs*
+ parameters merged.
+
+ Raise `~psycopg.ProgrammingError` if the input don't make a valid conninfo.
+
+ .. __: https://www.postgresql.org/docs/current/libpq-connect.html
+ #LIBPQ-CONNSTRING
"""
if not conninfo and not kwargs:
return ""
"""
Convert the *conninfo* string into a dictionary of parameters.
+ :param conninfo: A `connection string`__ as accepted by PostgreSQL.
+ :param kwargs: Parameters overriding the ones specified in *conninfo*.
+ :return: Dictionary with the parameters parsed from *conninfo* and
+ *kwargs*.
+
Raise ProgrammingError if the string is not valid.
+
+ .. __: https://www.postgresql.org/docs/current/libpq-connect.html
+ #LIBPQ-CONNSTRING
"""
opts = _parse_conninfo(conninfo)
rv = {