Mercurial > hg > ZDBInterface
diff DBInterface.py @ 8:17b19345d011
added autocommit option.
author | casties |
---|---|
date | Thu, 17 Feb 2011 19:25:16 +0100 |
parents | 1b25a85a2165 |
children | 22c16a632909 |
line wrap: on
line diff
--- a/DBInterface.py Tue Feb 15 21:14:03 2011 +0100 +++ b/DBInterface.py Thu Feb 17 19:25:16 2011 +0100 @@ -70,10 +70,11 @@ class DBInterface: """Object for database queries""" - def __init__(self, connection_id=None): + def __init__(self, connection_id=None, autocommit=False): """init""" # database connection id - self.connection_id = connection_id + self.connection_id = connection_id + self.autocommit = autocommit def getConnectionIDs(self): """return list of available connection ids""" @@ -94,6 +95,10 @@ con = getattr(self, self.connection_id) # call to get db object db = con() + if self.autocommit: + # force our transaction isolation level + db.tilevel = psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT + return db def executeZSQL(self, query, args=None, max_rows=None):