pgconsole/database.py
changeset 76 3a41b351b122
parent 10 f3a1b9792cc9
equal deleted inserted replaced
75:39f777341db4 76:3a41b351b122
    35 
    35 
    36     def connect(self, conninfo):
    36     def connect(self, conninfo):
    37         try:
    37         try:
    38             conn = psycopg2.connect(conninfo, async=1)
    38             conn = psycopg2.connect(conninfo, async=1)
    39             psycopg2.extras.wait_select(conn)
    39             psycopg2.extras.wait_select(conn)
    40         except psycopg2.DatabaseError, e:
    40         except psycopg2.DatabaseError as e:
    41             raise DatabaseError(str(e))
    41             raise DatabaseError(str(e))
    42         return conn
    42         return conn
    43 
    43 
    44 
    44 
    45     def get_conn(self, conninfo):
    45     def get_conn(self, conninfo):
    69         try:
    69         try:
    70             curs = conn.cursor()
    70             curs = conn.cursor()
    71             curs.execute(q, args)
    71             curs.execute(q, args)
    72             psycopg2.extras.wait_select(curs.connection)
    72             psycopg2.extras.wait_select(curs.connection)
    73 #            conn.commit()
    73 #            conn.commit()
    74         except psycopg2.OperationalError, e:
    74         except psycopg2.OperationalError as e:
    75             # disconnected?
    75             # disconnected?
    76 #            conn.rollback()
    76 #            conn.rollback()
    77             conn.close()
    77             conn.close()
    78             raise BadConnectionError(str(e))
    78             raise BadConnectionError(str(e))
    79         except psycopg2.DatabaseError, e:
    79         except psycopg2.DatabaseError as e:
    80 #            conn.rollback()
    80 #            conn.rollback()
    81             raise DatabaseError(str(e), curs.query)
    81             raise DatabaseError(str(e), curs.query)
    82         return curs
    82         return curs
    83 
    83 
    84 
    84