Search code examples
pythondatabasepython-db-api

DB-API x database module


What is a DB-API (Python) and what is a database module and how do they interact ?

I have a TCC project and I need to understand the difference and the purpose of these terms. I thought DB-API was, for example, a driver like psycopg2 but psycopg2 is a driver and has another purpose. If I'm wrong, correct me.


Solution

  • DB-API is a specification that SQL database modules written in Python adhere to.

    • psycopg2 is a DB-API compliant module for PostgreSQL,
    • mysqlclient is a DB-API compliant module for MySQL,
    • cx_Oracle is a DB-API compliant module for Oracle,

    etc.