O'Reilly logo

Python Programming On Win32 by Mark Hammond, Andy Robinson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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; an Error (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 Cursor object 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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required