Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are there Python ORMs out there that support multiple independent databases concurrently in use?

Tags:

python

orm

I'm writing an application in Python where I wish to use sqlite as the backing store for documents edited by the app, with documents generally living in memory, but being saved to disk-based databases when the application saves.

Ideally I'd like to use something like an ORM to make access to the data from my Python application code simple. Unfortunately it seems like the majority of Python ORMs, including SQLAlchemy, SQLObject, Django, and Storm, associate the database connection (or engine or whatever) with the classes representing table data, rather than instances of those classes. This restricts these ORMs to working with a single database connection across all instances. Since I'd like to support having multiple documents open simultaneously, this isn't going to work for me.

Are there any ORMs out there that support this usage model in Python? Bazaar seems to support this, but it's quite out of date, and at first glance appears to have some other shortcomings.

Thanks for any suggestions!

like image 780
sdt Avatar asked Feb 19 '26 05:02

sdt


2 Answers

The upcoming django 1.2 release supports this.

Here's a description of it: http://djangoadvent.com/1.2/multiple-database-support/

like image 96
ablerman Avatar answered Feb 22 '26 01:02

ablerman


SQLAlchemy does support multiple database connections per class, as in this example: http://svn.sqlalchemy.org/sqlalchemy/trunk/examples/sharding/attribute_shard.py

like image 37
Daniel Dourvaris Avatar answered Feb 22 '26 01:02

Daniel Dourvaris



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!