Revision 2190
Added by Aaron Marcuse-Kubitza over 12 years ago
lib/sql.py | ||
---|---|---|
142 | 142 |
log_debug_none = lambda msg: None |
143 | 143 |
|
144 | 144 |
class DbConn: |
145 |
def __init__(self, db_config, serializable=True, log_debug=log_debug_none,
|
|
146 |
caching=True): |
|
145 |
def __init__(self, db_config, serializable=True, autocommit=False,
|
|
146 |
caching=True, log_debug=log_debug_none):
|
|
147 | 147 |
self.db_config = db_config |
148 | 148 |
self.serializable = serializable |
149 |
self.autocommit = autocommit |
|
150 |
self.caching = caching |
|
149 | 151 |
self.log_debug = log_debug |
150 |
self.caching = caching |
|
151 | 152 |
|
152 | 153 |
self.__db = None |
153 | 154 |
self.query_results = {} |
... | ... | |
182 | 183 |
self.__db = module.connect(**db_config) |
183 | 184 |
|
184 | 185 |
# Configure connection |
185 |
if self.serializable: run_raw_query(self, |
|
186 |
'SET TRANSACTION ISOLATION LEVEL SERIALIZABLE') |
|
186 |
self.db.autocommit = self.autocommit |
|
187 |
if self.serializable and not self.autocommit: |
|
188 |
self.db.set_session(isolation_level='SERIALIZABLE') |
|
187 | 189 |
if schemas != None: |
188 | 190 |
schemas_ = ''.join((esc_name(self, s)+', ' |
189 | 191 |
for s in schemas.split(','))) |
Also available in: Unified diff
sql.py: DbConn: Added autocommit option to turn on autocommit mode. Use set_session() instead of SQL command to set isolation level.