diff options
author | Oleksandr Shulgin <oleksandr.shulgin@zalando.de> | 2015-10-27 17:37:18 +0100 |
---|---|---|
committer | Oleksandr Shulgin <oleksandr.shulgin@zalando.de> | 2015-10-27 17:37:18 +0100 |
commit | 433fb957cbca459810eaa2c962bf4b6c5d4fac0d (patch) | |
tree | 1bc4066e2a81b8cecd8203189dae391747688785 /doc | |
parent | 4b9a6f48f33f9f80a1a12850f5029bf7ab97145b (diff) | |
parent | 7aba8b3ed0483c675d757bf52c8ce9456c9aeeb1 (diff) | |
download | psycopg2-433fb957cbca459810eaa2c962bf4b6c5d4fac0d.tar.gz |
Merge branch 'feature/connect2' into feature/replication-protocol
Diffstat (limited to 'doc')
-rw-r--r-- | doc/src/extensions.rst | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/doc/src/extensions.rst b/doc/src/extensions.rst index d96cca4..dcaa234 100644 --- a/doc/src/extensions.rst +++ b/doc/src/extensions.rst @@ -24,6 +24,28 @@ functionalities defined by the |DBAPI|_. >>> psycopg2.extensions.parse_dsn('dbname=test user=postgres password=secret') {'password': 'secret', 'user': 'postgres', 'dbname': 'test'} +.. function:: make_dsn(**kwargs) + + Wrap keyword parameters into a connection string, applying necessary + quoting and escaping any special characters (namely, single quote and + backslash). + + Example (note the order of parameters in the resulting string is + arbitrary):: + + >>> psycopg2.extensions.make_dsn(dbname='test', user='postgres', password='secret') + 'user=postgres dbname=test password=secret' + + As a special case, the *database* keyword is translated to *dbname*:: + + >>> psycopg2.extensions.make_dsn(database='test') + 'dbname=test' + + An example of quoting (using `print()` for clarity):: + + >>> print(psycopg2.extensions.make_dsn(database='test', password="some\\thing ''special")) + password='some\\thing \'\'special' dbname=test + .. class:: connection(dsn, async=False) Is the class usually returned by the `~psycopg2.connect()` function. |