2

Is Python DB-API 2.0 for relational database only, or also for some nonrelational databases?

https://wiki.python.org/moin/DatabaseInterfaces seems to imply no.

https://wiki.python.org/moin/DatabaseProgramming seems to imply yes.

Thanks.

1 Answer 1

2

Although the DatabaseProgramming link you provided considers DB-API an interface specification for relational databases, I do not see where the actual PEP 249 would make any restriction to a certain type of DB engine/architecture. However, both, the wiki page and the PEP have been authored by Marc-André Lemburg, so he might have written the PEP with mainly relational databases in mind.

From my point of view, the interface specification is abstract enough to also fit non-relational data sources. As a matter of fact, I once wrote an adapter for a Rest-API in front of a huge mongo database. That adapter widely implemented DB-API 2.0 in order to unify access to data from various sources (ODBC, JDBC, the said mongo DB behind the Rest service).

I would argue that, if a developer sees benefit in implementing access to a data source following the DB-API 2.0 specs and he does so consistently, there's no reason why such an implementation should be considered wrong or un-pythonic.

I mean, one could even wrap access to file objects in DB-API compliant constructs without making it look completely stupid or fully useless ...

Sign up to request clarification or add additional context in comments.

1 Comment

This is interesting! Wanted someone to confirm this hunch for me regarding PEP 249.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.