Skip to content

Commit

Permalink
Force psycopg to decode strings received from database to unicode.
Browse files Browse the repository at this point in the history
Unicode data caused queries to output nothing and exit with an
UnicodeDecodeError.
  • Loading branch information
macobo committed Jan 6, 2015
1 parent f3f8c92 commit 4aaa117
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pgcli/pgexecute.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import logging
import psycopg2
import psycopg2.extensions
from .packages import pgspecial

_logger = logging.getLogger(__name__)

# Cast all database input to unicode automatically.
# See http://initd.org/psycopg/docs/usage.html#unicode-handling for more info.
psycopg2.extensions.register_type(psycopg2.extensions.UNICODE)
psycopg2.extensions.register_type(psycopg2.extensions.UNICODEARRAY)

def _parse_dsn(dsn, default_user, default_password, default_host,
default_port):
"""
Expand Down

0 comments on commit 4aaa117

Please sign in to comment.