pythonsqlalchemypython-db-api

doubts about DB-API e SQLAlchemy


link da questão

enter image description here

Briefly, I want to know what this "DB-API" mechanism is.

Are there multiple DB-APIs (there are more than 1 DB-API)?

Is it just a 'rules' document?

have a source code?

What is it for?

Is psycopg2 an example of a DB-API or is it a library that follows DB-APIs standards?

Is the DB-API specified in SQLAlchemy a SQLAlchemy-specific DB-API (if that is possible)?

I think that's it !!!

Regarding the dialect, I ask another question later.


Solution

  • The python db api is defined in https://www.python.org/dev/peps/pep-0249/ and I believe just a spec or as you say rules document.

    Modules like psycopg2 fulfill those requirements, so are an implementation of that api. SqlAlchemy allows you to swap out which db api implementation you use so you can change your underlying database server or use features offered by another driver/db api implementation and still use the same database server.

    As I understand it SqlAlchemy supports multiple db api implementations which you specify using a connection uri, explained here https://docs.sqlalchemy.org/en/13/core/engines.html#database-urls.