Connection Objects
Connection
objects should respond to the following
methods:
-
close() Closes the connection now (rather than whenever
__del_ _is called). The connection is unusable from this point forward; anError(or subclass) exception is raised if any operation is attempted with the connection. The same applies to all cursor objects trying to use the connection.-
commit() Commits any pending transaction to the database. Note that if the database supports an auto-commit feature, this must be initially off. An interface method may be provided to turn it back on.
Database modules that don’t support transactions should implement this method with void functionality.
-
rollback() This method is optional since not all databases provide transaction support.Note 3
In case a database does provide transactions, this method causes the database to roll back to the start of any pending transaction. Closing a connection without committing the changes first causes an implicit rollback to be performed.
-
cursor() Returns a new
Cursorobject using the connection. If the database doesn’t provide a direct cursor concept, the module has to emulate cursors using other means to the extent needed by this specification.Note 4
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access