472,347 Members | 2,294 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,347 software developers and data experts.

retrieve data from 2 database

Hi,

How do I select data from two tables from two different databases and
compare them? using dbi,odbc

Jul 28 '05 #1
3 2158
For a start, asking a better question will get better answers:
http://www.catb.org/~esr/faqs/smart-questions.html

Googling for python odbc gives this as the first result:
http://www.python.org/windows/win32/odbc.html

In general, how you compare database tables will depend a lot on the
nature of the tables: e.g. are you comparing names to names, rows to
rows, apples to oranges, etc.?

Jul 28 '05 #2
On 27 Jul 2005 20:18:55 -0700, "crespoh" <cr*****@gmail.com> declaimed
the following in comp.lang.python:
Hi,

How do I select data from two tables from two different databases and
compare them? using dbi,odbc
1) Does "two different databases" mean two different DBMSs, or just
two logically distinct databases withing one DBMS?

Some DBMS allow for accessing across "database" boundaries (as
long as both are maintained within the same DBMS) without using a second
connection. (MySQL, for example, looks to allow "select ... from
db_name.table_name..." to cross boundaries.)

2) Do you mean two tables in /each/ "database" (four tables total)
or one in each "database"?

Offhand, if you can do cross-bounds queries, you can probably
use one query/cursor/connection.

select d1.t.f1 as d1f1, d1.t.f2 as d1f2, ... d2.t.f1 as d2f1,
d2.t.f2 as d2f2... from d1.t, d2.t where...

and then run a test comparing all the d1f* to d2f*

Otherwise, you may need two cursors to allow for independent
retrieves...

But maybe you want something like a DIFF report, and the tables
won't match row for row. For that, you will need to write a DIFF style
compare loop, and have cursors that can be rewound (or fetchall into
local data types that you can index).

-- ================================================== ============ <
wl*****@ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG <
wu******@dm.net | Bestiaria Support Staff <
================================================== ============ <
Home Page: <http://www.dm.net/~wulfraed/> <
Overflow Page: <http://wlfraed.home.netcom.com/> <

Jul 28 '05 #3
crespoh wrote:
Hi,

How do I select data from two tables from two different databases and
compare them? using dbi,odbc

Well, a lot depends on the database. If it's two Access .mdb files, for
example, or two different databases in a single SQL Server instance,
sometimes you can use SQL statements that cross-refer. Not possible with
ODBC, though, I fear.

In that case, we have to hope that the datasets are small enough to hold
in memory, as Python data structures, and then operate on them as Python
sets or some such. The DB API delivers the results of queries as lists
of tuples, each tuple representing a row, but of course they can easily
be transformed into other Python objects with more convenient properties
to join the two sets together.

Much then depends on how you want to join the two sets.

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/

Jul 28 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Daniel Tonks | last post by:
First, please excuse the fact that I'm a complete MySQL newbie. My site used forum software that I wrote myself (in Perl) which, up until now,...
4
by: Claudia Fong | last post by:
Hi, I have a form where I need to display the data of a department that stores in a access db. When I first load the form it will call a...
5
by: Roy Gourgi | last post by:
Hi, I am used to working in Visual FoxPro and I would like to be able to create a database and store and retrieve information from it. What is...
5
by: ggk517 | last post by:
We are trying to develop an Engineering application using PHP, Javascript with Informix as the back-end. Is it possible to retrieve data using...
13
by: kev | last post by:
Hi all, I have created a database for equipments. I have a form to register the equipment meaning filling in all the particulars (ID, serial,...
3
by: Alfred | last post by:
I want to post text field data from these HTML TEXTAREA tags to a PostgreSQL database and have it reappear back on another page exactly as I had...
1
by: Mel | last post by:
Anyone know how I would retrieve the MaxLength property of a column in my Access Database table? I know how to retrieve table data, for example...
5
by: fruityfreak | last post by:
I would like to know how to I retrieve information from another database table... Instead of keying in manually, I would like to retrieve data...
0
by: tigger | last post by:
Hi there, I'm having problems retrieving data from Access database using Visual basic 2005. My database is called Actual_Database and...
21
by: giandeo | last post by:
Hello Experts. Is it possible to retrieve the value from a populated pull down menu from a database and then use that value to access the same...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.