Saturday, October 6, 2012

Python and Database Connectivity

The Python standard for database interfaces is the Python DB-API. Most Python database interfaces adhere to this standard. Python Database API provides a standard Interface to interact between Python and different Databases. DB API 2.0 is the current DB API version, and is referenced as PEP 249

The popular Python DB API 2.0 compatible modules are as below :-
  • sqlite (sqlite3) - This is a built-in module and comes with the standard python installation.
The DB API provides a minimal standard for working with databases, using Python structures and syntax wherever possible. This API includes the following :-

  • Importing the API module.
  • Connection objects  
    • Opening a connection to the database.
    • Perform Transactions (Commit/Rollback) 
  • Cursor Objects
    • SQL Statement execution (manipulate a query the database)
    • Access to results
  • Closing the database connection