As I mentioned earlier, the Python standard library does not come with an RDBMS interface, but there are many free third-party modules that let your Python programs access specific databases. Such modules mostly follow the Python Database API 2.0 standard, also known as the DBAPI.
At the time of this writing, Python’s DBAPI Special Interest Group (SIG) was busy preparing a new version of the DBAPI (possibly to be known as 3.0 when it is ready). Programs written against DBAPI 2.0 should work with minimal or no changes with the future DBAPI 3.0, although 3.0 will no doubt offer further enhancements that future programs will be able to take advantage of.
If your Python program runs only
on Windows, you may prefer to access databases by using
ADO package through
COM. For more information on using Python on
Windows, see the book Python Programming on Win32, by Mark Hammond and Andy Robinson
(O’Reilly). Since ADO and COM are platform-specific,
and this book focuses on cross-platform use of Python, I do not cover
ADO nor COM further in this book.
After importing a DBAPI-compliant module, you call the
connect function with
connect returns an instance
Connection, which represents a connection
to the database. This instance supplies
rollback methods to let you deal with
close method to call as soon as
you’re done with the database, and a
cursor method that returns an instance ...