1
0
Fork 0

More intelligent dsn format (#1045)

* Psycopg2 already has a method to format a dsn. We should use it. Fix for #1043.

* Changelog.

* pep8.
This commit is contained in:
Irina Truong 2019-04-28 15:06:01 -07:00 committed by GitHub
parent 9a53fe859a
commit 3fd91012f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 5 deletions

View File

@ -6,6 +6,7 @@ Bug fixes:
* Escape switches to VI navigation mode when not canceling completion popup. (Thanks: `Nathan Verzemnieks`_)
* Allow application_name to be overridden. (Thanks: `raylu`_)
* Fix for "no attribute KeyringLocked" (#1040). (Thanks: `Irina Truong`_)
* Pgcli no longer works with password containing spaces (#1043). (Thanks: `Irina Truong`_)
2.1.0
=====
@ -960,4 +961,5 @@ Improvements:
.. _`Scott Brenstuhl`: https://github.com/808sAndBR
.. _`easteregg`: https://github.com/verfriemelt-dot-org
.. _`Nathan Verzemnieks`: https://github.com/njvrzm
.. _`raylu`: https://github.com/benchling
.. _`raylu`: https://github.com/raylu

View File

@ -7,7 +7,7 @@ import psycopg2.extensions as ext
import sqlparse
import pgspecial as special
import select
from psycopg2.extensions import POLL_OK, POLL_READ, POLL_WRITE
from psycopg2.extensions import POLL_OK, POLL_READ, POLL_WRITE, make_dsn
from .packages.parseutils.meta import FunctionMetadata, ForeignKey
from .encodingutils import unicode2utf8, PY2, utf8tounicode
@ -238,9 +238,8 @@ class PGExecute(object):
})
if 'password' in conn_params and 'dsn' in conn_params:
conn_params['dsn'] = "{0} password={1}".format(
conn_params['dsn'], conn_params.pop('password')
)
conn_params['dsn'] = make_dsn(
conn_params['dsn'], password=conn_params.pop('password'))
conn = psycopg2.connect(**conn_params)
cursor = conn.cursor()