Mercurial > p > roundup > code
changeset 5751:5cb6e6b594b0
issue2551040: New release of psycopg2 drops support for psycopg1
First try at suport for psycopg2. Change .travis.yml to install newest
psycopg2 without psycopg1 support.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sat, 01 Jun 2019 15:47:34 -0400 |
| parents | 2c0f89edabe1 |
| children | 4c0cdfe4f678 |
| files | .travis.yml CHANGES.txt roundup/backends/back_postgresql.py test/test_postgresql.py |
| diffstat | 4 files changed, 16 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/.travis.yml Sat Jun 01 13:19:14 2019 -0400 +++ b/.travis.yml Sat Jun 01 15:47:34 2019 -0400 @@ -67,7 +67,7 @@ install: - pip install mysqlclient==1.3.13 - - pip install psycopg2==2.7.7 + - pip install psycopg2 - pip install gpg pytz whoosh - pip install pytest-cov codecov
--- a/CHANGES.txt Sat Jun 01 13:19:14 2019 -0400 +++ b/CHANGES.txt Sat Jun 01 15:47:34 2019 -0400 @@ -138,6 +138,8 @@ code to make sure valid backend database is set. Remove config.ini from templates to make sure that roundup-admin install writes a new default config.ini based on configuration.py. +- issue2551040: New release of psycopg2 drops support for psycopg1 - + need to rewrite. Now uses psycopg2 throughout. (John Rouillard) 2018-07-13 1.6.0
--- a/roundup/backends/back_postgresql.py Sat Jun 01 13:19:14 2019 -0400 +++ b/roundup/backends/back_postgresql.py Sat Jun 01 15:47:34 2019 -0400 @@ -4,7 +4,7 @@ # under the same terms as Python, so long as this copyright message and # disclaimer are retained in their original form. # -'''Postgresql backend via psycopg for Roundup.''' +'''Postgresql backend via psycopg2 for Roundup.''' __docformat__ = 'restructuredtext' import os, shutil, time @@ -13,13 +13,13 @@ ISOLATION_LEVEL_REPEATABLE_READ = None ISOLATION_LEVEL_SERIALIZABLE = None -from psycopg2 import psycopg1 as psycopg +import psycopg2 from psycopg2.extensions import QuotedString from psycopg2.extensions import ISOLATION_LEVEL_READ_UNCOMMITTED from psycopg2.extensions import ISOLATION_LEVEL_READ_COMMITTED from psycopg2.extensions import ISOLATION_LEVEL_REPEATABLE_READ from psycopg2.extensions import ISOLATION_LEVEL_SERIALIZABLE -from psycopg2.psycopg1 import ProgrammingError +from psycopg2 import ProgrammingError from psycopg2.extensions import TransactionRollbackError import logging @@ -66,15 +66,15 @@ fail by conflicting with another user. Since PostgreSQL version 8.1 there is a database "postgres", - before "template1" seems to habe been used, so we fall back to it. + before "template1" seems to have been used, so we fall back to it. Compare to issue2550543. ''' template1 = connection_dict(config) template1['database'] = database try: - conn = psycopg.connect(**template1) - except psycopg.OperationalError as message: + conn = psycopg2.connect(**template1) + except psycopg2.OperationalError as message: if str(message).find('database "postgres" does not exist') >= 0: return db_command(config, command, database='template1') raise hyperdb.DatabaseError(message) @@ -97,7 +97,7 @@ ''' try: cursor.execute(command) - except psycopg.DatabaseError as err: + except psycopg2.DatabaseError as err: response = str(err).split('\n')[0] if "FATAL" not in response : msgs = ( @@ -115,7 +115,7 @@ """Check if database already exists""" db = connection_dict(config, 'database') try: - conn = psycopg.connect(**db) + conn = psycopg2.connect(**db) conn.close() return 1 except: @@ -156,8 +156,8 @@ logging.getLogger('roundup.hyperdb').info( 'open database %r'%db['database']) try: - conn = psycopg.connect(**db) - except psycopg.OperationalError as message: + conn = psycopg2.connect(**db) + except psycopg2.OperationalError as message: raise hyperdb.DatabaseError(message) cursor = conn.cursor() @@ -245,7 +245,7 @@ return '<roundpsycopgsql 0x%x>' % id(self) def sql_stringquote(self, value): - ''' psycopg.QuotedString returns a "buffer" object with the + ''' psycopg2.QuotedString returns a "buffer" object with the single-quotes around it... ''' return str(QuotedString(str(value)))[1:-1]
--- a/test/test_postgresql.py Sat Jun 01 13:19:14 2019 -0400 +++ b/test/test_postgresql.py Sat Jun 01 15:47:34 2019 -0400 @@ -34,7 +34,7 @@ reason='Skipping PostgreSQL tests: backend not available')) else: try: - from roundup.backends.back_postgresql import psycopg, db_command + from roundup.backends.back_postgresql import psycopg2, db_command db_command(config, 'select 1') skip_postgresql = lambda func, *args, **kwargs: func except( DatabaseError ) as msg: @@ -110,7 +110,7 @@ try: self.db1.close() self.db2.close() - except psycopg.InterfaceError as exc: + except psycopg2.InterfaceError as exc: if 'connection already closed' in str(exc): pass else: raise ClassicInitBase.tearDown(self)
