[DB-SIG] connect to multiple databases at the same time

M.-A. Lemburg mal at egenix.com
Tue May 19 11:30:03 CEST 2009

zongzhi liu wrote:
> I am using sqlite3 a lot.  As a database growing larger and larger, I would
> like to seperate some tables into another database.  In sqlite3, you can use
> something like:
> select * from db_a.table1 join db_b.table1 using (ID)
> However, I cannot figure out how to use such statement in python.  You help
> will be greatly appreciated.

That would be a cross-database join. A few databases are able to
handle such joins, e.g. DB2. You have to define access to the
second DB in the first DB and then have the database engine
apply the join for you.

In Python, you'd simply run the query and get back the results.

There are also meta-drivers which provide a similar logic without
the need to modify the databases, e.g.


You can use our mxODBC to access this driver from Python.

Marc-Andre Lemburg

Professional Python Services directly from the Source  (#1, May 19 2009)
>>> Python/Zope Consulting and Support ...        http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
2009-06-29: EuroPython 2009, Birmingham, UK                40 days to go

::: Try our new mxODBC.Connect Python Database Interface for free ! ::::

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611

More information about the DB-SIG mailing list