RE: DBI->installed_drivers() usage

RE: DBI->installed_drivers() usage

am 20.07.2006 00:20:06 von pgriffin

Phillip,

Many thanks.

Regards Paul...

-----Original Message-----
From: Garrett, Philip (MAN-Corporate) [mailto:Philip.Garrett@manheim.com]
Sent: Wednesday, July 19, 2006 11:25 PM
To: Paul Griffin; dbi-users@perl.org
Subject: RE: DBI->installed_drivers() usage

Paul Griffin wrote:
> I'm running Win XP with Perl 5.8.8.
>
> If I try and run the following code :
>
> use DBI;
> my %drivers = DBI->installed_drivers();
> foreach (keys( %drivers)) {
> print "$_ uses $drivers{$_}\n";
> }
>
> Nothing is returned. Yet if I use :
>
> my @drivers = DBI->available_drivers();
>
> I get a list of drivers that I can then access with :
>
> @dataSources = DBI->data_sources($_);
>
> Am I using DBI->installed_drivers() incorrectly?

DBI->installed_drivers returns only the drivers that are actually loaded
into the current process. Installed in this case means "installed into
memory."

This code will load all the drivers (generally not a good thing) and
then list them with installed_drivers():

use DBI;
eval { DBI->install_driver($_) }
foreach DBI->available_drivers;
my %drivers = DBI->installed_drivers;
print "$_: $drivers{$_}\n" foreach sort keys %drivers;

Philip