Hacker News new | ask | show | jobs
by anewhnaccount2 1782 days ago
There is https://www.python.org/dev/peps/pep-0249/ . I suppose part of the issue is that there is probably deviation from the standard and lots of extensions. I imagine that the standard means there is a lot of shared code between the different connectors though.
1 comments

As far as I know, there is zero or close to zero shared code.

PEP 249 is great to have, and it's nice to at least have a starting point for learning a new database connector library.

But not all database connector libraries implement the specification. One well-known library [0] explicitly and deliberately violates the spec with no spec-compliant "escape hatch". Also the style of passing parameters as a single sequence (e.g. list or tuple) tends to be a newbie trap, and having 4 different placeholder styles can be annoying.

That said, there are ODBC connector libraries [1] if you really do need a uniform interface. But at that point you might be better off with the SQLAlchemy "Core" query builder [2].

[0]: Asyncpg, https://magicstack.github.io/asyncpg/

[1]: https://wiki.python.org/moin/ODBC

[2]: https://docs.sqlalchemy.org/en/14/core/