diff options
author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2017-02-03 04:56:02 +0000 |
---|---|---|
committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2017-02-03 04:56:02 +0000 |
commit | de8b335d80ecba0305e2b4796373a4064fd450b3 (patch) | |
tree | 26a5fab1a9f022adda5d5ad2de78b816fe0350e1 /lib/__init__.py | |
parent | a8a3a298f8ade3b0430ff2df0a5d5ee1fe920e3d (diff) | |
parent | ca42306d7916647448184907e03c77ff54ebd4f9 (diff) | |
download | psycopg2-sql-compose.tar.gz |
Merge branch 'master' into sql-composesql-compose
Diffstat (limited to 'lib/__init__.py')
-rw-r--r-- | lib/__init__.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/__init__.py b/lib/__init__.py index fb22b4c..492b924 100644 --- a/lib/__init__.py +++ b/lib/__init__.py @@ -82,8 +82,7 @@ else: del Decimal, Adapter -def connect(dsn=None, connection_factory=None, cursor_factory=None, - async=False, **kwargs): +def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): """ Create a new database connection. @@ -111,17 +110,24 @@ def connect(dsn=None, connection_factory=None, cursor_factory=None, Using the *cursor_factory* parameter, a new default cursor factory will be used by cursor(). - Using *async*=True an asynchronous connection will be created. + Using *async*=True an asynchronous connection will be created. *async_* is + a valid alias (for Python versions where ``async`` is a keyword). Any other keyword parameter will be passed to the underlying client library: the list of supported parameters depends on the library version. """ + kwasync = {} + if 'async' in kwargs: + kwasync['async'] = kwargs.pop('async') + if 'async_' in kwargs: + kwasync['async_'] = kwargs.pop('async_') + if dsn is None and not kwargs: raise TypeError('missing dsn and no parameters') dsn = _ext.make_dsn(dsn, **kwargs) - conn = _connect(dsn, connection_factory=connection_factory, async=async) + conn = _connect(dsn, connection_factory=connection_factory, **kwasync) if cursor_factory is not None: conn.cursor_factory = cursor_factory |