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
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
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
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
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
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
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
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
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
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
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
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
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
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
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