Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

DBD Drivers query

by costas (Scribe)
on Apr 05, 2001 at 18:10 UTC ( #70105=perlquestion: print w/replies, xml ) Need Help??
costas has asked for the wisdom of the Perl Monks concerning the following question:

I have installed DBI and have just installed DBD-mysql (from activestate) and it seemed to install fine.

I have done

#!/usr/bin/perl -w use strict; use DBI; #probe DBI for available drivers my @drivers = DBI->available_drivers(); ##iterate through drivers and list the data source for each one foreach my $driver (@drivers) { print "Driver: $driver\n"; my @datasources = DBI->data_sources($driver); foreach my $datasource (@datasources) { print "\tData Source is $datasource\n"; } print "\n"; } exit;

After running this I get

Driver: ExampleP Data Source is dbi:ExampleP:dir=. Driver: Multiplex Driver: Proxy

If i succesfully installed DBD-mysql then it should show here? (is this right). Does anyone have any answers


Replies are listed 'Best First'.
Re: DBD Drivers query
by arturo (Vicar) on Apr 05, 2001 at 18:23 UTC

    It should show up with that technique; if you just want to see whether that particular module's installed (i.e. you're not trying to get a full list of what drivers you have installed), try

    perl -MDBD::Mysql -e '1'

    in a DOS window, and see if you get an error (you might want to check my captialization on the module name, just to be sure.)

    If that doesn't work, try it by hand: execute perl -V in a DOS window and look at the @INC directories; poke through them for a file in a directory that looks like DBD\


    Philosophy can be made out of anything. Or less -- Jerry A. Fodor

      Hi i tried typing

      perl -MDBD::Mysql -e '1'

      and i did not get an error, i got no feedback at all.

      I also checked in c:\perl\site\dbd\ and exists.

Re: DBD Drivers query
by sutch (Curate) on Apr 05, 2001 at 21:10 UTC
    When I run your script, an error about DBD::Proxy and the mysql driver info is never displayed. I believe the problem has something to do with this line, though I'm not sure what the actual problem is:

    my @datasources = DBI->data_sources($driver);

    If I remove the statements that deal with the data_sources, it works fine:

    #!/usr/bin/perl use strict; use DBI; my @drivers = DBI->available_drivers(); die "No drivers found!\n" unless @drivers; foreach my $driver ( @drivers ) { print "Driver: $driver\n"; }

    Which returns:

    Driver: ADO Driver: ExampleP Driver: Oracle Driver: Pg Driver: Proxy Driver: mysql

    Maybe DBD::Proxy has a problem with data_sources?

      Sutch, this works exactly the same for me.

      Once I removed that line I get

      Driver: ExampleP Driver: Multiplex Driver: Proxy Driver: mysql

      Does this glitch have any affect on any of the drivers (in particular mysql). Are these driver working functionaly, as normal, in other words will i have any problems using these drivers later on?
        Without reading up too much about why DBD::Proxy may be choking on the data_sources call, I did find that DBD::Proxy should not have any effect on Mysql. From the DBD::Proxy documentation:

        DBD::Proxy is a Perl module for connecting to a database via a remote DBI driver.

        This is of course not needed for DBI drivers which already support connecting to a remote database, but there are engines which don't offer network connectivity.

        I would suggest limiting your data_sources method calls to only driver(s) that your are going to use. For example, use a conditional such as if ($driver eq 'mysql') so that only the mysql driver is queried for data_sources.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://70105]
Approved by root
and the fog begins to lift...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2018-05-27 18:45 GMT
Find Nodes?
    Voting Booth?