tags:

views:

220

answers:

1

In an ORM you can have nice syntax like this:

my $results = Model.objects.all()[10];

And in the Django ORM it even quite nicely handles foreign key relationships and many to many relationships all through the ORM.

However, in MySQL you can run a query like this:

SELECT t1.column1
,      t2.column2
,      t3.column3
FROM   db1.table AS t1
,      db2.table AS t2
,      db3.table AS t3
WHERE  t1.id = t2.t1_id
AND    t1.id = t3.t1_id 
LIMIT  0,10

I'm looking for an ORM that can support these types of query natively but can't really see anything that does.

Are there any existing ORMs that can do this? Or are there alternative strategies for tackling this problem?

Whenever I've used a framework like django to build a site, I've kept everything on the same database because I was aware of the limitation. Now I'm working with data that's spread across many different databases, for no apparent reason other than namespacing.

+2  A: 

Might be worth looking at something at a lower level than the ORM? For example, something along the lines of C-JDBC provides a 'virtual' database driver that talks to a cluster of databases behind the scenes. (Tables can be distributed across servers)

(I realise you're using Python, so this specific example would only be of use if you could run Jython on the JVM as a platform integrating that way - however I'm guessing similar libraries probably exist closer suited to your specific requirements)

alasdairg
Thanks, that's a pretty good suggestion.
David McLaughlin
I checked out the C-JDBC page and after a bit of reading, came across the Tungsten Connector http://community.continuent.com/community/tungsten-connector it is for Sequoia the continuation of C-JDBC. Should work with Python
Philip T.