Package backend :: Package server :: Package rhnSQL :: Module sql_base :: Class Cursor
[hide private]
[frames] | no frames]

Class Cursor

source code


A class to implement generic SQL Cursor operations.

Instance Methods [hide private]
 
__init__(self, dbh=None, sql=None, force=None) source code
 
_prepare_sql(self) source code
 
_prepare(self, force=None) source code
 
prepare(self, sql, force=None)
Prepares the current statement.
source code
 
update_blob(self, table_name, column_name, where_clause, data, **kwargs)
Abstraction for the update of a blob column which can vary wildly between different database implementations.
source code
 
execute(self, *p, **kw)
Execute a single query.
source code
 
executemany(self, *p, **kw)
Execute a query multiple times with different data sets.
source code
 
execute_bulk(self, dict, chunk_size=100)
Uses executemany but chops the incoming dict into chunks for each call.
source code
 
_execute_wrapper(self, function, *p, **kw)
Database specific execute wrapper.
source code
 
_execute(self, *args, **kwargs) source code
 
_executemany(self, *args, **kwargs) source code
 
_execute_(self, args, kwargs)
Database specific execution of the query.
source code
 
fetchone(self) source code
 
fetchall(self) source code
 
fetchone_dict(self)
Return a dictionary for the row returned mapping column name to it's value.
source code
 
fetchall_dict(self)
Fetch all rows as a list of dictionaries.
source code
 
_is_sequence_type(self, val) source code
Class Variables [hide private]
  _cursor_cache = {}
Method Details [hide private]

prepare(self, sql, force=None)

source code 

Prepares the current statement.

Must be called prior to execute even if the underlying database driver does not support an explicit prepare before execution.

executemany(self, *p, **kw)

source code 

Execute a query multiple times with different data sets.

Call with keyword arguments mapping to ordered lists. i.e. cursor.executemany(id=[1, 2], name=["Bill", "Mary"])

execute_bulk(self, dict, chunk_size=100)

source code 

Uses executemany but chops the incoming dict into chunks for each call.

When attempting to execute bulk operations with a lot of rows in the arrays, Oracle may occasionally lock (probably the oracle client library). I noticed this previously with the import code. -- misa This function executes bulk operations in smaller chunks dict is supposed to be the dictionary that we normally apply to statement.execute.

_execute_wrapper(self, function, *p, **kw)

source code 

Database specific execute wrapper. Mostly used just to catch DB exceptions and wrap them.

Must be subclasses by database specific drivers.