jplindstrom has asked for the wisdom of the Perl Monks concerning the following question:

I wonder if there is any way to know the DBI driver or connect string given an already connected $dbh. Like 'Sybase' or 'Oracle'.

I tried the get_info() method, but (at least for SQLite) all values are undefined, so feeding it 17 (which should be the DBMS name) didn't work. Or maybe if it's just the SQLite driver that's not fully functional. For me it's enough if I can identify when I connected to a Sybase database.

  • Comment on DBI driver/connect string from the $dbh

Replies are listed 'Best First'.
Re: DBI driver/connect string from the $dbh
by blokhead (Monsignor) on Feb 28, 2004 at 22:23 UTC
    $dbh->{Driver}{Name} gives you the driver name. It's worked fine for me in SQLite too. It'll be the same string as the name of the DBD::xxxx module (mysql, SQLite, Sybase, Pg). See DBI under "Driver (handle)".

    blokhead

      Excellent, thank you!