Пример #1
0
 def execute_sql(self,
                 sql,
                 params=None,
                 require_commit=True,
                 named_cursor=False):
     logger.debug((sql, params))
     use_named_cursor = (named_cursor
                         or (self.server_side_cursors
                             and sql.lower().startswith('select')))
     with self.exception_wrapper():
         if use_named_cursor:
             cursor = self.get_cursor(name=str(uuid.uuid1()))
             require_commit = False
         else:
             cursor = self.get_cursor()
         try:
             cursor.execute(sql, params or ())
         except Exception as exc:
             logger.exception('%s %s', sql, params)
             if self.get_autocommit() and self.autorollback:
                 self.rollback()
             if self.sql_error_handler(exc, sql, params, require_commit):
                 raise
         else:
             if require_commit and self.get_autocommit():
                 self.commit()
     return cursor
Пример #2
0
 def execute_sql(self, sql, params=None, require_commit=True):
     logger.debug((sql, params))
     with self.exception_wrapper():
         cursor = self.get_cursor()
         wrap_transaction = require_commit and self.get_autocommit()
         with _execute_wrapper(self, cursor, wrap_transaction):
             self._execute_sql(cursor, sql, params)
     return cursor
Пример #3
0
 def execute_sql(self, sql, params=None, require_commit=True):
     logger.debug((sql, params))
     with self.exception_wrapper():
         cursor = self.get_cursor()
         wrap_transaction = require_commit and self.get_autocommit()
         with _execute_wrapper(self, cursor, wrap_transaction):
             self._execute_sql(cursor, sql, params)
     return cursor
Пример #4
0
 def execute_sql(self, sql, params=None, require_commit=True):
     logger.debug((sql, params))
     with self.exception_wrapper():
         cursor = self.get_cursor()
         require_commit = sql.lower().startswith(
             ('insert', 'delete', 'update'))
         wrap_transaction = require_commit and self.get_autocommit()
         with _execute_wrapper(self, cursor, sql, params, wrap_transaction):
             self._execute_sql(cursor, sql, params)
     return cursor
Пример #5
0
 def execute_sql(self, sql, params=None, require_commit=True):
     logger.debug((sql, params))
     with self.exception_wrapper():
         cursor = self.get_cursor()
         try:
             self._execute_sql(cursor, sql, params)
         except Exception as exc:
             if self.sql_error_handler(exc, sql, params, require_commit):
                 raise
     return cursor
Пример #6
0
 def execute_sql(self, sql, params=None, require_commit=True):
     logger.debug((sql, params))
     with self.exception_wrapper():
         cursor = self.get_cursor()
         try:
             self._execute_sql(cursor, sql, params)
         except Exception as exc:
             if self.sql_error_handler(exc, sql, params, require_commit):
                 raise
     return cursor
Пример #7
0
 def execute(self, sql, params=None, require_commit=True):
     cursor = self.get_cursor()
     wrap_transaction = require_commit and self.get_autocommit()
     if wrap_transaction:
         cursor.execute('begin;')
     res = cursor.execute(sql, params or ())
     if wrap_transaction:
         cursor.execute('commit;')
     logger.debug((sql, params))
     return cursor
Пример #8
0
 def execute_sql(self, sql, params=None, require_commit=True):
     logger.debug((sql, params))
     with self.exception_wrapper():
         cursor = self.get_cursor()
         require_commit = sql.lower().startswith(
             ('insert', 'delete', 'update'))
         wrap_transaction = require_commit and self.get_autocommit()
         with _execute_wrapper(self, cursor, sql, params, wrap_transaction):
             self._execute_sql(cursor, sql, params)
     return cursor
Пример #9
0
 async def execute_sql(self, sql, params=None, require_commit=True):
     logger.debug((sql, params))
     with self.exception_wrapper:
         cursor = await self.conn.cursor()
         try:
             await cursor.execute(sql, params or ())
         except Exception:
             if self.autorollback and self.autocommit:
                 await self.rollback()
             raise
         else:
             if require_commit and self.autocommit:
                 await self.commit()
         return cursor
Пример #10
0
 def execute_sql(self, sql, params=None, require_commit=True):
     logger.debug((sql, params))
     with self.exception_wrapper():
         cursor = self.get_cursor()
         try:
             cursor.execute(Drill.sql_fill_params(sql, params))
         except Exception:
             if self.get_autocommit() and self.autorollback:
                 self.rollback()
             raise
         else:
             if require_commit and self.get_autocommit():
                 self.commit()
     return cursor
Пример #11
0
 def execute_sql(self, sql, params=None, require_commit=True,
                 named_cursor=False):
     logger.debug((sql, params))
     use_named_cursor = (named_cursor or (
                         self.server_side_cursors and
                         sql.lower().startswith('select')))
     if use_named_cursor:
         cursor = self.get_cursor(name=str(uuid.uuid1()))
         require_commit = False
     else:
         cursor = self.get_cursor()
     res = cursor.execute(sql, params or ())
     if require_commit and self.get_autocommit():
         self.commit()
     return cursor
Пример #12
0
 def execute_sql(self, sql, params=None, require_commit=True):
     cursor = self.get_cursor()
     wrap_transaction = require_commit and self.get_autocommit()
     if wrap_transaction:
         cursor.execute('begin;')
         try:
             self._execute_sql(cursor, sql, params)
         except:
             cursor.execute('rollback;')
             raise
         else:
             cursor.execute('commit;')
     else:
         cursor = self._execute_sql(cursor, sql, params)
     logger.debug((sql, params))
     return cursor
Пример #13
0
 def execute_sql(self, sql, params=None, require_commit=True):
     cursor = self.get_cursor()
     wrap_transaction = require_commit and self.get_autocommit()
     if wrap_transaction:
         cursor.execute('begin;')
         try:
             self._execute_sql(cursor, sql, params)
         except:
             cursor.execute('rollback;')
             raise
         else:
             cursor.execute('commit;')
     else:
         cursor = self._execute_sql(cursor, sql, params)
     logger.debug((sql, params))
     return cursor
Пример #14
0
 def execute_sql(self,
                 sql,
                 params=None,
                 require_commit=True,
                 named_cursor=False):
     logger.debug((sql, params))
     use_named_cursor = (named_cursor
                         or (self.server_side_cursors
                             and sql.lower().startswith('select')))
     if use_named_cursor:
         cursor = self.get_cursor(name=str(uuid.uuid1()))
         require_commit = False
     else:
         cursor = self.get_cursor()
     res = cursor.execute(sql, params or ())
     if require_commit and self.get_autocommit():
         self.commit()
     return cursor
Пример #15
0
 def execute_sql(self, sql, params=None, require_commit=True,
                 named_cursor=False):
     logger.debug((sql, params))
     use_named_cursor = (named_cursor or (
                         self.server_side_cursors and
                         sql.lower().startswith('select')))
     if use_named_cursor:
         cursor = self.get_cursor(name=str(uuid.uuid1()))
         require_commit = False
     else:
         cursor = self.get_cursor()
     try:
         res = cursor.execute(sql, params or ())
     except Exception as exc:
         logger.error('Error executing query %s (%s)' % (sql, params))
         return self.sql_error_handler(exc, sql, params, require_commit)
     if require_commit and self.get_autocommit():
         self.commit()
     return cursor
Пример #16
0
 def execute_sql(self, sql, params=None, require_commit=True, named_cursor=False):
     logger.debug((sql, params))
     use_named_cursor = named_cursor or (self.server_side_cursors and sql.lower().startswith("select"))
     with self.exception_wrapper():
         if use_named_cursor:
             cursor = self.get_cursor(name=str(uuid.uuid1()))
             require_commit = False
         else:
             cursor = self.get_cursor()
         try:
             cursor.execute(sql, params or ())
         except Exception as exc:
             if self.get_autocommit() and self.autorollback:
                 self.rollback()
             raise
         else:
             if require_commit and self.get_autocommit():
                 self.commit()
     return cursor
Пример #17
0
 def execute_sql(self,
                 sql,
                 params=None,
                 require_commit=True,
                 named_cursor=False):
     logger.debug((sql, params))
     use_named_cursor = (named_cursor
                         or (self.server_side_cursors
                             and sql.lower().startswith('select')))
     if use_named_cursor:
         cursor = self.get_cursor(name=str(uuid.uuid1()))
         require_commit = False
     else:
         cursor = self.get_cursor()
     try:
         res = cursor.execute(sql, params or ())
     except Exception as exc:
         logger.error('Error executing query %s (%s)' % (sql, params))
         return self.sql_error_handler(exc, sql, params, require_commit)
     if require_commit and self.get_autocommit():
         self.commit()
     return cursor
Пример #18
0
 def execute_sql(self, sql, params=None, require_commit=True):
     logger.debug((sql, params))
     with self.exception_wrapper():
         cursor = self.get_cursor()
         self._execute_sql(cursor, sql, params)
     return cursor
Пример #19
0
 def execute_sql(self, sql, params=None, commit=True):
     logger.debug((sql, params))
     with __exception_wrapper__:
         cursor = self.cursor()
         cursor.execute(sql, params or ())
     return cursor
Пример #20
0
 def execute_sql(self, sql, params=None, commit=True):
     logger.debug((sql, params))
     with __exception_wrapper__:
         cursor = self.cursor()
         cursor.execute(sql, params or ())
     return cursor
Пример #21
0
 def execute_sql(self, sql, params=None, require_commit=True):
     logger.debug((sql, params))
     with self.exception_wrapper():
         cursor = self.get_cursor()
         self._execute_sql(cursor, sql, params)
     return cursor