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'
andstate='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 awith
statement, otherwiseFalse
.
-