diff options
-rwxr-xr-x | pgcli/main.py | 2 | ||||
-rw-r--r-- | pgcli/packages/pgspecial.py | 4 | ||||
-rw-r--r-- | pgcli/pgexecute.py | 18 | ||||
-rw-r--r-- | setup.py | 2 | ||||
-rw-r--r-- | tests/test_pgexecute.py | 8 | ||||
-rw-r--r-- | tests/utils.py | 4 |
6 files changed, 19 insertions, 19 deletions
diff --git a/pgcli/main.py b/pgcli/main.py index 94bd6db6..0bc8abe2 100755 --- a/pgcli/main.py +++ b/pgcli/main.py @@ -37,7 +37,7 @@ try: except ImportError: from urllib.parse import urlparse from getpass import getuser -from psycopg2 import OperationalError +from psycopg2cffi import OperationalError from collections import namedtuple diff --git a/pgcli/packages/pgspecial.py b/pgcli/packages/pgspecial.py index 48efb82a..e597e6fb 100644 --- a/pgcli/packages/pgspecial.py +++ b/pgcli/packages/pgspecial.py @@ -892,8 +892,8 @@ def execute(cur, sql): return [(None, None, cur.statusmessage)] if __name__ == '__main__': - import psycopg2 - con = psycopg2.connect(database='misago_testforum') + import psycopg2cffi + con = psycopg2cffi.connect(database='misago_testforum') cur = con.cursor() table = sys.argv[1] for rows, headers, status in describe_table_details(cur, table, False): diff --git a/pgcli/pgexecute.py b/pgcli/pgexecute.py index 093314dd..d9ef2471 100644 --- a/pgcli/pgexecute.py +++ b/pgcli/pgexecute.py @@ -1,7 +1,7 @@ import logging -import psycopg2 -import psycopg2.extras -import psycopg2.extensions as ext +import psycopg2cffi +import psycopg2cffi.extras +import psycopg2cffi.extensions as ext import sqlparse from .packages import pgspecial from .encodingutils import unicode2utf8 @@ -10,19 +10,19 @@ _logger = logging.getLogger(__name__) # Cast all database input to unicode automatically. # See http://initd.org/psycopg/docs/usage.html#unicode-handling for more info. -ext.register_type(psycopg2.extensions.UNICODE) -ext.register_type(psycopg2.extensions.UNICODEARRAY) +ext.register_type(psycopg2cffi.extensions.UNICODE) +ext.register_type(psycopg2cffi.extensions.UNICODEARRAY) ext.register_type(ext.new_type((705,), "UNKNOWN", ext.UNICODE)) ext.register_type(ext.new_type((51766,), "HSTORE", ext.UNICODE)) # Cast bytea fields to text. By default, this will render as hex strings with # Postgres 9+ and as escaped binary in earlier versions. -psycopg2.extensions.register_type( - psycopg2.extensions.new_type((17,), 'BYTEA_TEXT', psycopg2.STRING)) +psycopg2cffi.extensions.register_type( + psycopg2cffi.extensions.new_type((17,), 'BYTEA_TEXT', psycopg2cffi.STRING)) # When running a query, make pressing CTRL+C raise a KeyboardInterrupt # See http://initd.org/psycopg/articles/2014/07/20/cancelling-postgresql-statements-python/ -psycopg2.extensions.set_wait_callback(psycopg2.extras.wait_select) +psycopg2cffi.extensions.set_wait_callback(psycopg2cffi.extras.wait_select) class PGExecute(object): @@ -89,7 +89,7 @@ class PGExecute(object): password = unicode2utf8(password or self.password) host = unicode2utf8(host or self.host) port = unicode2utf8(port or self.port) - conn = psycopg2.connect(database=db, user=user, password=password, + conn = psycopg2cffi.connect(database=db, user=user, password=password, host=host, port=port) if hasattr(self, 'conn'): self.conn.close() @@ -27,7 +27,7 @@ setup( 'Pygments >= 2.0', # Pygments has to be Capitalcased. WTF? 'jedi == 0.8.1', # Temporary fix for installation woes. 'prompt_toolkit==0.26', - 'psycopg2 >= 2.5.4', + 'psycopg2cffi >= 2.5.4', 'sqlparse >= 0.1.14' ], entry_points=''' diff --git a/tests/test_pgexecute.py b/tests/test_pgexecute.py index e9c97e36..56bb8ba9 100644 --- a/tests/test_pgexecute.py +++ b/tests/test_pgexecute.py @@ -1,7 +1,7 @@ # coding=UTF-8 import pytest -import psycopg2 +import psycopg2cffi from textwrap import dedent from utils import run, dbtest @@ -54,13 +54,13 @@ def test_database_list(executor): @dbtest def test_invalid_syntax(executor): - with pytest.raises(psycopg2.ProgrammingError) as excinfo: + with pytest.raises(psycopg2cffi.ProgrammingError) as excinfo: run(executor, 'invalid syntax!') assert 'syntax error at or near "invalid"' in str(excinfo.value) @dbtest def test_invalid_column_name(executor): - with pytest.raises(psycopg2.ProgrammingError) as excinfo: + with pytest.raises(psycopg2cffi.ProgrammingError) as excinfo: run(executor, 'select invalid command') assert 'column "invalid" does not exist' in str(excinfo.value) @@ -89,7 +89,7 @@ def test_multiple_queries_same_line(executor): @dbtest def test_multiple_queries_same_line_syntaxerror(executor): - with pytest.raises(psycopg2.ProgrammingError) as excinfo: + with pytest.raises(psycopg2cffi.ProgrammingError) as excinfo: run(executor, "select 'foo'; invalid syntax") assert 'syntax error at or near "invalid"' in str(excinfo.value) diff --git a/tests/utils.py b/tests/utils.py index 9b7376f1..158fa1e3 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -1,5 +1,5 @@ import pytest -import psycopg2 +import psycopg2cffi from pgcli.main import format_output # TODO: should this be somehow be divined from environment? @@ -7,7 +7,7 @@ POSTGRES_USER, POSTGRES_HOST = 'postgres', 'localhost' def db_connection(dbname=None): - conn = psycopg2.connect(user=POSTGRES_USER, host=POSTGRES_HOST, dbname=dbname) + conn = psycopg2cffi.connect(user=POSTGRES_USER, host=POSTGRES_HOST, dbname=dbname) conn.autocommit = True return conn |