RE: DBI->installed_drivers() usage

RE: DBI->installed_drivers() usage

am 19.07.2006 15:24:53 von Philip.Garrett

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

Philip

Re: DBI->installed_drivers() usage

am 19.07.2006 17:37:27 von Tim.Bunce

On Wed, Jul 19, 2006 at 09:24:53AM -0400, Garrett, Philip (MAN-Corporate) wrote:
> 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."

Ah. The docs weren't clear:


--- DBI.pm (revision 6618)
+++ DBI.pm (working copy)
@@ -2753,10 +2753,15 @@

%drivers = DBI->installed_drivers();

-Returns a list of driver name and driver handle pairs for all
-installed drivers. The driver name does not include the 'DBD::'
-prefix. Added in DBI 1.49.
+Returns a list of driver name and driver handle pairs for all drivers
+'installed' (loaded) into the current process. The driver name does not
+include the 'DBD::' prefix.

+To get a list of all drivers available in your perl instalation you can use
+L.
+
+Added in DBI 1.49.
+
=item C

DBI->installed_versions;

Tim.