diff options
author | Irina Truong <i.chernyavska@gmail.com> | 2019-04-28 15:06:01 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-28 15:06:01 -0700 |
commit | 3fd91012f20faef6f823cae3b0ba970181e30c75 (patch) | |
tree | 543dce7bdae3493bbb94a98b010bc5f1455e8c94 | |
parent | 9a53fe859acbbf833c05f14e673d5cc76e5fe135 (diff) |
More intelligent dsn format (#1045)
* Psycopg2 already has a method to format a dsn. We should use it. Fix for #1043.
* Changelog.
* pep8.
-rw-r--r-- | changelog.rst | 4 | ||||
-rw-r--r-- | pgcli/pgexecute.py | 7 |
2 files changed, 6 insertions, 5 deletions
diff --git a/changelog.rst b/changelog.rst index 91f908a5..fa7d402d 100644 --- a/changelog.rst +++ b/changelog.rst @@ -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 + diff --git a/pgcli/pgexecute.py b/pgcli/pgexecute.py index a0c7dc9e..8e5616f7 100644 --- a/pgcli/pgexecute.py +++ b/pgcli/pgexecute.py @@ -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() |