44# under the same terms as Python, so long as this copyright message and
55# disclaimer are retained in their original form.
66#
7- '''Postgresql backend via psycopg for Roundup.'''
7+ '''Postgresql backend via psycopg2 for Roundup.'''
88__docformat__ = 'restructuredtext'
99
1010import os , shutil , time
1313ISOLATION_LEVEL_REPEATABLE_READ = None
1414ISOLATION_LEVEL_SERIALIZABLE = None
1515
16- from psycopg2 import psycopg1 as psycopg
16+ import psycopg2
1717from psycopg2 .extensions import QuotedString
1818from psycopg2 .extensions import ISOLATION_LEVEL_READ_UNCOMMITTED
1919from psycopg2 .extensions import ISOLATION_LEVEL_READ_COMMITTED
2020from psycopg2 .extensions import ISOLATION_LEVEL_REPEATABLE_READ
2121from psycopg2 .extensions import ISOLATION_LEVEL_SERIALIZABLE
22- from psycopg2 . psycopg1 import ProgrammingError
22+ from psycopg2 import ProgrammingError
2323from psycopg2 .extensions import TransactionRollbackError
2424
2525import logging
@@ -66,15 +66,15 @@ def db_command(config, command, database='postgres'):
6666 fail by conflicting with another user.
6767
6868 Since PostgreSQL version 8.1 there is a database "postgres",
69- before "template1" seems to habe been used, so we fall back to it.
69+ before "template1" seems to have been used, so we fall back to it.
7070 Compare to issue2550543.
7171 '''
7272 template1 = connection_dict (config )
7373 template1 ['database' ] = database
7474
7575 try :
76- conn = psycopg .connect (** template1 )
77- except psycopg .OperationalError as message :
76+ conn = psycopg2 .connect (** template1 )
77+ except psycopg2 .OperationalError as message :
7878 if str (message ).find ('database "postgres" does not exist' ) >= 0 :
7979 return db_command (config , command , database = 'template1' )
8080 raise hyperdb .DatabaseError (message )
@@ -97,7 +97,7 @@ def pg_command(cursor, command):
9797 '''
9898 try :
9999 cursor .execute (command )
100- except psycopg .DatabaseError as err :
100+ except psycopg2 .DatabaseError as err :
101101 response = str (err ).split ('\n ' )[0 ]
102102 if "FATAL" not in response :
103103 msgs = (
@@ -115,7 +115,7 @@ def db_exists(config):
115115 """Check if database already exists"""
116116 db = connection_dict (config , 'database' )
117117 try :
118- conn = psycopg .connect (** db )
118+ conn = psycopg2 .connect (** db )
119119 conn .close ()
120120 return 1
121121 except :
@@ -156,8 +156,8 @@ def sql_open_connection(self):
156156 logging .getLogger ('roundup.hyperdb' ).info (
157157 'open database %r' % db ['database' ])
158158 try :
159- conn = psycopg .connect (** db )
160- except psycopg .OperationalError as message :
159+ conn = psycopg2 .connect (** db )
160+ except psycopg2 .OperationalError as message :
161161 raise hyperdb .DatabaseError (message )
162162
163163 cursor = conn .cursor ()
@@ -245,7 +245,7 @@ def __repr__(self):
245245 return '<roundpsycopgsql 0x%x>' % id (self )
246246
247247 def sql_stringquote (self , value ):
248- ''' psycopg .QuotedString returns a "buffer" object with the
248+ ''' psycopg2 .QuotedString returns a "buffer" object with the
249249 single-quotes around it... '''
250250 return str (QuotedString (str (value )))[1 :- 1 ]
251251
0 commit comments