There is no Python equivalent to Perl's DBI-centric ecosystem. Instead:
- The DBAPI (PEP 249) defines a common low-level interface that relational database drivers are expected to provide.
- Some projects like SQLAlchemy Core abstract over multiple drivers, using the common DBAPI interface.
Python's lack of a proper DBI equivalent is less of a disadvantage than it would be in Perl due to the different module system. Assuming you are restricting yourself to a common SQL subset and to the DBAPI instead of using driver-specific extensions, switching to a different driver can be as simple as changing an import, and updating the connection information:
- import somedatabase as db
+ import differentdriver as db
In practice, neither Python's DBAPI nor Perl's DBI will enable you to switch databases at a whim. However, Perl's DBI makes it much easier to write software that works with multiple databases.