Use psycopg2 PgSQL module
This commit is contained in:
parent
64efcb0fd8
commit
7825748a26
1 changed files with 3 additions and 3 deletions
|
@ -1,5 +1,5 @@
|
||||||
from . import ModuleBase
|
from . import ModuleBase
|
||||||
from pyPgSQL import PgSQL
|
import psycopg2
|
||||||
|
|
||||||
class Module(ModuleBase):
|
class Module(ModuleBase):
|
||||||
def __init__(self, manager):
|
def __init__(self, manager):
|
||||||
|
@ -17,12 +17,12 @@ class Module(ModuleBase):
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
self.db = PgSQL.connect(host = self.conf['host'], user = self.conf['user'], password = self.conf['passwd'], database = self.conf['db'], client_encoding = 'utf8', unicode_results = 1)
|
self.db = psycopg2.connect(host = self.conf['host'], user = self.conf['user'], password = self.conf['passwd'], database = self.conf['db'])
|
||||||
|
|
||||||
def cursor(self):
|
def cursor(self):
|
||||||
try:
|
try:
|
||||||
return self.db.cursor()
|
return self.db.cursor()
|
||||||
except PgSQL.OperationalError:
|
except psycopg2.OperationalError:
|
||||||
self._connect()
|
self._connect()
|
||||||
return self.db.cursor()
|
return self.db.cursor()
|
||||||
|
|
||||||
|
|
Reference in a new issue