Starting new project: database abstraction in Python, best practice for retaining option of MySQL or PostgreSQL without ORM
I want to retain the flexibility of switching between MySQL and PostgreSQL without the awkwardness of using an ORM - SQL is a fantastic language and i would like to retain it's power wi开发者_如何学运维thout the additional overhead of an ORM.
So...is there a best practice for abstraction the database layer of a Python application to provide the stated flexibility.
Thanks community!
While SQLAlchemy is a great option. There are others. If you find that SQLAlchemy is not to your liking here are some other ORMs that may work out better for you. Some of them are more lightweight, so it may be more what you're looking for.
http://coobs.eu.org/xrecord/ -- From the description sounds like what you may be looking for. It sounds pretty lightweight and just a database abstraction, but seems to be a little outdated.
http://autumn-orm.org/
http://charlesleifer.com/blog/peewee-a-lightweight-python-orm/ -- includes benchmarks that look pretty good for the basic uses that are done.
http://elixir.ematia.de/trac/wiki -- This is built on top of SQLAlchemy, but has the ActiveRecord style syntax. It may be more to your liking.
https://storm.canonical.com/FrontPage -- An ORM used by Canonical.
Have a look at SQLAlchemy. You can use it to execute literal SQL on several RDBMS, including MySQL and PostgreSQL. It wraps the DB-API adapters with a common interface, so they will behave as similarly as possible.
SQLAlchemy also offers programmatic generation of SQL, with or without the included ORM, which you may find very useful.
精彩评论