Accessing Pervasive.SQL With Perl

Page Last Modified: 03/02/10

Home Links ODBC (DBI) Contact

DBI + ODBC - Checking available drivers and datasources example

use strict;
use warnings;

use DBI;

print "Drivers:\n";
my @drivers = DBI->available_drivers;
foreach my $driver (@drivers)
{
print "$driver\n";
}

print "Data sources:\n";
foreach my $driver (@drivers)
{
print "$driver\n";
eval {
my @dataSources = DBI->data_sources($driver);

foreach my $dataSource (@dataSources)
{
print "\t$dataSource\n";
}
1;
} or do {
print "Driver error: $@\n";
};
}

With my ActiveState Perl 5.8 development machine I do not have various modules installed for drivers like DBD::Proxy to work, and as a result when data_sources is called for these drivers the sample code throws an exception. The eval block has been added to catch these and keep the code running so that all of the drivers are tested for datasources even though various error messages might get displayed.

Home Links ODBC (DBI) Contact

All content on this site is copyright
Neil Hughes 2010 - 2018