1
0
Fork 0

Use psycopg2 to get database details

This commit is contained in:
François Pietka 2017-07-29 15:59:30 +02:00
parent 323fda4b9c
commit f63081495c
No known key found for this signature in database
GPG Key ID: 6EBE6B5C5C1B1B59
2 changed files with 6 additions and 4 deletions

View File

@ -10,7 +10,7 @@ Features:
Bug Fixes:
----------
There are no bugs :)
* Fix the way we get host when using DSN (issue #765) (Thanks: `François Pietka`_)
1.7.0
=====

View File

@ -203,9 +203,11 @@ 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.
db, user, host, port = self._select_one(
cursor,
'select current_database(), current_user, inet_server_addr(), inet_server_port()')
dsn_parameters = conn.get_dsn_parameters()
db = dsn_parameters['dbname']
user = dsn_parameters['user']
host = dsn_parameters['host']
port = dsn_parameters['port']
self.dbname = db
self.user = user