Add doSQL and close methods
This commit is contained in:
parent
de9472a08a
commit
a3cca712c2
1 changed files with 18 additions and 0 deletions
18
PgDB.py
18
PgDB.py
|
@ -28,6 +28,10 @@ class PgDB(object):
|
|||
logging.fatal(e)
|
||||
sys.exit(1)
|
||||
|
||||
def close(self):
|
||||
if self.con:
|
||||
self.con.close()
|
||||
|
||||
def setEncoding(self,enc):
|
||||
if self.con:
|
||||
try:
|
||||
|
@ -37,6 +41,20 @@ class PgDB(object):
|
|||
logging.error(e)
|
||||
return False
|
||||
|
||||
def doSQL(self,sql,params=None):
|
||||
cursor = self.con.cursor()
|
||||
try:
|
||||
if params is None:
|
||||
cursor.execute(sql)
|
||||
else:
|
||||
cursor.execute(sql,params)
|
||||
self.con.commit()
|
||||
return True
|
||||
except Exception, e:
|
||||
logging.error('Erreur durant la requete sql %s : %s' % (sql,e))
|
||||
self.con.rollback()
|
||||
return False
|
||||
|
||||
def doSelect(self,sql):
|
||||
cursor = self.con.cursor()
|
||||
try:
|
||||
|
|
Loading…
Reference in a new issue