Project

General

Profile

« Previous | Next » 

Revision 2683

sql.py: DbConn: Added with_autocommit()

View differences:

sql.py
331 331
    def is_cached(self, query, params=None):
332 332
        return _query_lookup(query, params) in self.query_results
333 333
    
334
    def with_autocommit(self, func, autocommit=True):
335
        prev_autocommit = self.db.autocommit
336
        self.db.autocommit = autocommit
337
        try: return func()
338
        finally: self.db.autocommit = prev_autocommit
339
    
334 340
    def with_savepoint(self, func):
335 341
        savepoint = 'level_'+str(self._savepoint)
336 342
        self.run_query('SAVEPOINT '+savepoint, log_level=4)
337 343
        self._savepoint += 1
338
        try: 
344
        try:
339 345
            try: return_val = func()
340 346
            finally:
341 347
                self._savepoint -= 1

Also available in: Unified diff