CursorManager

class privex.db.base.CursorManager(cursor: CUR, close_callback: Optional[callable] = None)[source]

Not all database API’s support context management with their cursors, so this class wraps a given database cursor objects, and provides context management methods __enter__() and __exit__()

__init__(cursor: CUR, close_callback: Optional[callable] = None)[source]

Initialise the cursor manager.

Parameters
  • cursor (CUR|GenericCursor) – A database cursor object to wrap

  • close_callback (callable) – If specified, this callable (function/method) will be called BEFORE and AFTER the cursor is closed, with the kwargs state='BEFORE_CLOSE' and state='AFTER_CLOSE' respectively.

can_cleanup = None

This becomes True if this is the first context manager instance for a cursor

is_context_manager = None

True if this class is being used in a with statement, otherwise False.

Methods

Methods

__init__(cursor[, close_callback])

Initialise the cursor manager.

close(*args, **kwargs)

execute(*args, **kwargs)

fetchall(*args, **kwargs)

fetchmany(*args, **kwargs)

fetchone(*args, **kwargs)

Attributes

Attributes

description

lastrowid

rowcount