I have to compare columns of tables located in two different databases in two different servers. So far, I know how to connect to one server & one database using Perl script. Is it possible to connect to two different servers using Perl's DBI module? If so, how?
+10
A:
You connect to a database using DBI->connect()
. This returns a handle to that database. To connect to two databases, use two handles:
my $dbh1 = DBI->connect($connectstr1, $user1, $password1,
{ PrintError => 1, AutoCommit => 1 });
my $dbh2 = DBI->connect($connectstr2, $user2, $password2,
{ PrintError => 1, AutoCommit => 1 });
Now you can use $dbh1
for the first database, and $dbh2
for the second.
Andomar
2009-11-19 17:09:54