mirror of https://github.com/dbcli/pgcli
Merge pull request #1112 from dbcli/j-bennet/pqconninfo-1110
[WIP] Fix for PQconninfo not available.
This commit is contained in:
commit
f3dc23a94b
|
@ -11,12 +11,13 @@ Features:
|
|||
Bug fixes:
|
||||
----------
|
||||
|
||||
* Error connecting to PostgreSQL 12beta1 (#1058). (Thanks: `Irina Truong`_)
|
||||
* Error connecting to PostgreSQL 12beta1 (#1058). (Thanks: `Irina Truong`_ and `Amjith Ramanujam`_)
|
||||
* Empty query caused error message (#1019) (Thanks: `Sebastian Janko`_)
|
||||
* History navigation bindings in multiline queries (#1004) (Thanks: `Pedro Ferrari`_)
|
||||
* Can't connect to pgbouncer database (#1093). (Thanks: `Irina Truong`_)
|
||||
* Fix broken multi-line history search (#1031). (Thanks: `Owen Stephens`_)
|
||||
* Fix slow typing/movement when multi-line query ends in a semicolon (#994). (Thanks: `Owen Stephens`_)
|
||||
* Fix for PQconninfo not available in libpq < 9.3 (#1110). (Thanks: `Irina Truong`_)
|
||||
|
||||
Internal:
|
||||
---------
|
||||
|
|
|
@ -265,14 +265,32 @@ class PGExecute(object):
|
|||
# When we connect using a DSN, we don't really know what db,
|
||||
# user, etc. we connected to. Let's read it.
|
||||
# Note: moved this after setting autocommit because of #664.
|
||||
# TODO: use actual connection info from psycopg2.extensions.Connection.info as psycopg>2.8 is available and required dependency # noqa
|
||||
dsn_parameters = conn.get_dsn_parameters()
|
||||
libpq_version = psycopg2.__libpq_version__
|
||||
dsn_parameters = {}
|
||||
if libpq_version >= 93000:
|
||||
# use actual connection info from psycopg2.extensions.Connection.info
|
||||
# as libpq_version > 9.3 is available and required dependency
|
||||
dsn_parameters = conn.info.dsn_parameters
|
||||
else:
|
||||
try:
|
||||
dsn_parameters = conn.get_dsn_parameters()
|
||||
except Exception as x:
|
||||
# https://github.com/dbcli/pgcli/issues/1110
|
||||
# PQconninfo not available in libpq < 9.3
|
||||
_logger.info("Exception in get_dsn_parameters: %r", x)
|
||||
|
||||
if dsn_parameters:
|
||||
self.dbname = dsn_parameters.get("dbname")
|
||||
self.user = dsn_parameters.get("user")
|
||||
self.host = dsn_parameters.get("host")
|
||||
self.port = dsn_parameters.get("port")
|
||||
else:
|
||||
self.dbname = conn_params.get("database")
|
||||
self.user = conn_params.get("user")
|
||||
self.host = conn_params.get("host")
|
||||
self.port = conn_params.get("port")
|
||||
|
||||
self.dbname = dsn_parameters.get("dbname")
|
||||
self.user = dsn_parameters.get("user")
|
||||
self.password = password
|
||||
self.host = dsn_parameters.get("host")
|
||||
self.port = dsn_parameters.get("port")
|
||||
self.extra_args = kwargs
|
||||
|
||||
if not self.host:
|
||||
|
|
Loading…
Reference in New Issue