On Sep 11, 2009, at 9:03 PM, Jeff Johnson wrote: > I am using Dabo to access a MSSQL Server and a PostgreSQL Server. It > was pretty easy to get two connections going. PostgreSQL is my app > connection. Is it possible to do a select statement on a table from a > database in one connection and a table from a database in another > connection? > > Here is what I want to do: > > SELECT * from mstable ; > where not exists(select * from pgtable ; > where mstable.pk = pgtable.pk) > > The purpose is to find records in the MS table that don't exist in the > PG table so I can add them.
As others have pointed out, you can't query across connections. How big are the tables? If they aren't huge, you might try something like this: use the PostgreSQL cursor to grab all the PKs from the pgtable into a tuple, and then grab the mscursor's records. Something like this: sql = "select pk from pgtable" pgcursor.execute(sql) pgpks = tuple([rec["pk"] for rec in pgcursor.getDataSet()]) sql = """select * from mstable where mstable.pk not in %s; """ mscursor.execute(sql, pgpks) -- Ed Leafe _______________________________________________ Post Messages to: Dabo-users@leafe.com Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users Searchable Archives: http://leafe.com/archives/search/dabo-users This message: http://leafe.com/archives/byMID/25f09b3e-d5e0-48a5-9b65-9f59932e3...@leafe.com