ORM solutions for multi-database queries

In ORM, you can have nice syntax like this:

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

      

And in the Django ORM, it even handles foreign key relationships pretty well and many, many relationships 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 queries natively, but can't see anything it does.

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

Whenever I used a framework like django to build a site, I kept everything in one database because I knew about the limitation. Now I'm working with data that spreads across many different databases, for no apparent reason other than the namespace.

0


source to share


1 answer


Perhaps it is worth looking at something at a lower level than the ORM? For example, something like C-JDBC provides a "virtual" database driver that talks to the database cluster behind the scenes. (Tables can be shared across servers)



(I understand that you are using Python, so this particular example will only be useful if you can run Jython on the JVM as a platform integrating this path - however I guess similar libraries probably exist closer than yours specific requirements)

+2


source







All Articles