Benjamin Renard commited on 2015-04-01 15:52:32
Showing 1 changed files, with 18 additions and 0 deletions.
| ... | ... |
@@ -28,6 +28,10 @@ class PgDB(object): |
| 28 | 28 |
logging.fatal(e) |
| 29 | 29 |
sys.exit(1) |
| 30 | 30 |
|
| 31 |
+ def close(self): |
|
| 32 |
+ if self.con: |
|
| 33 |
+ self.con.close() |
|
| 34 |
+ |
|
| 31 | 35 |
def setEncoding(self,enc): |
| 32 | 36 |
if self.con: |
| 33 | 37 |
try: |
| ... | ... |
@@ -37,6 +41,20 @@ class PgDB(object): |
| 37 | 41 |
logging.error(e) |
| 38 | 42 |
return False |
| 39 | 43 |
|
| 44 |
+ def doSQL(self,sql,params=None): |
|
| 45 |
+ cursor = self.con.cursor() |
|
| 46 |
+ try: |
|
| 47 |
+ if params is None: |
|
| 48 |
+ cursor.execute(sql) |
|
| 49 |
+ else: |
|
| 50 |
+ cursor.execute(sql,params) |
|
| 51 |
+ self.con.commit() |
|
| 52 |
+ return True |
|
| 53 |
+ except Exception, e: |
|
| 54 |
+ logging.error('Erreur durant la requete sql %s : %s' % (sql,e))
|
|
| 55 |
+ self.con.rollback() |
|
| 56 |
+ return False |
|
| 57 |
+ |
|
| 40 | 58 |
def doSelect(self,sql): |
| 41 | 59 |
cursor = self.con.cursor() |
| 42 | 60 |
try: |
| 43 | 61 |