summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmjith Ramanujam <amjith.r@gmail.com>2015-02-08 14:54:57 -0800
committerAmjith Ramanujam <amjith.r@gmail.com>2015-02-08 14:54:57 -0800
commit7091dce672477e54a74210f7b412c8aa3d009365 (patch)
treec961e5cf6eaf03a916ec574e6464f0cc42045bef
parent767f1a7a097db4165f6029baf01d320b501c424f (diff)
Revert psycopg2cffi to psycopg2.
-rwxr-xr-xpgcli/main.py2
-rw-r--r--pgcli/packages/pgspecial.py4
-rw-r--r--pgcli/pgexecute.py18
-rw-r--r--tests/test_pgexecute.py8
-rw-r--r--tests/utils.py4
5 files changed, 18 insertions, 18 deletions
diff --git a/pgcli/main.py b/pgcli/main.py
index 0bc8abe2..94bd6db6 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 psycopg2cffi import OperationalError
+from psycopg2 import OperationalError
from collections import namedtuple
diff --git a/pgcli/packages/pgspecial.py b/pgcli/packages/pgspecial.py
index e597e6fb..48efb82a 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 psycopg2cffi
- con = psycopg2cffi.connect(database='misago_testforum')
+ import psycopg2
+ con = psycopg2.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 d9ef2471..093314dd 100644
--- a/pgcli/pgexecute.py
+++ b/pgcli/pgexecute.py
@@ -1,7 +1,7 @@
import logging
-import psycopg2cffi
-import psycopg2cffi.extras
-import psycopg2cffi.extensions as ext
+import psycopg2
+import psycopg2.extras
+import psycopg2.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(psycopg2cffi.extensions.UNICODE)
-ext.register_type(psycopg2cffi.extensions.UNICODEARRAY)
+ext.register_type(psycopg2.extensions.UNICODE)
+ext.register_type(psycopg2.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.
-psycopg2cffi.extensions.register_type(
- psycopg2cffi.extensions.new_type((17,), 'BYTEA_TEXT', psycopg2cffi.STRING))
+psycopg2.extensions.register_type(
+ psycopg2.extensions.new_type((17,), 'BYTEA_TEXT', psycopg2.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/
-psycopg2cffi.extensions.set_wait_callback(psycopg2cffi.extras.wait_select)
+psycopg2.extensions.set_wait_callback(psycopg2.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 = psycopg2cffi.connect(database=db, user=user, password=password,
+ conn = psycopg2.connect(database=db, user=user, password=password,
host=host, port=port)
if hasattr(self, 'conn'):
self.conn.close()
diff --git a/tests/test_pgexecute.py b/tests/test_pgexecute.py
index 56bb8ba9..e9c97e36 100644
--- a/tests/test_pgexecute.py
+++ b/tests/test_pgexecute.py
@@ -1,7 +1,7 @@
# coding=UTF-8
import pytest
-import psycopg2cffi
+import psycopg2
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(psycopg2cffi.ProgrammingError) as excinfo:
+ with pytest.raises(psycopg2.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(psycopg2cffi.ProgrammingError) as excinfo:
+ with pytest.raises(psycopg2.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(psycopg2cffi.ProgrammingError) as excinfo:
+ with pytest.raises(psycopg2.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 158fa1e3..9b7376f1 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -1,5 +1,5 @@
import pytest
-import psycopg2cffi
+import psycopg2
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 = psycopg2cffi.connect(user=POSTGRES_USER, host=POSTGRES_HOST, dbname=dbname)
+ conn = psycopg2.connect(user=POSTGRES_USER, host=POSTGRES_HOST, dbname=dbname)
conn.autocommit = True
return conn