Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

DBI->connect using 'old-style' syntax is deprecated and will be an error in future versions

by LameNerd (Hermit)
on Jul 15, 2003 at 23:54 UTC ( [id://274633]=perlquestion: print w/replies, xml ) Need Help??

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

Hi Monks,

I have moved my scripts to another server which I guess is using a newer version of DBI. I think this because I get this warning message:
DBI->connect using 'old-style' syntax is deprecated and will be an err +or in future versions ...

When my script executes ...
my $dbh = DBI->connect( $dbname, $dbuser, $dbpass, $dbd );
Here's my questions:
  • How should I be calling connect?
  • What was worng with the "old-style" syntax?
    Maybe this isn't a DBI issue at all?
  • Replies are listed 'Best First'.
    Re: DBI->connect using 'old-style' syntax is deprecated and will be an error in future versions
    by ScooterQ (Pilgrim) on Jul 16, 2003 at 00:48 UTC
      The "old style" error is because you're specifying the driver name as an argument. The following works, however (Postgresql in my case):
      my $dbh = DBI->connect("DBI:Pg:dbname=$database",$user,$password );
      I found this bit, straight from Tim Bunce (June 97, DBI-user mail list) which shows the difference between the two methods:
      Old-style: DBI->connect('dbname', $user, $pass, 'Driver'); New-style: DBI->connect('dbi:Driver:dbname', $user, $pass);
    Re: DBI->connect using 'old-style' syntax is deprecated and will be an error in future versions
    by DigitalKitty (Parson) on Jul 16, 2003 at 01:05 UTC
    Re: DBI->connect using 'old-style' syntax is deprecated and will be an error in future versions
    by Anonymous Monk on Jul 16, 2003 at 00:45 UTC

      What's the DBD and what are the contents of $dbname? Standard syntax (at least since I started using DBI) is:

      my $dbh = DBI->connect("DBI:ODBC:test_connection", $user, $passs, {opt +ions});

      So the first argument to connect is a connect string that includes the driver (DBD), as well as the specific connection (e.g. ODBC DSN, Oracle DBN, etc.). That appears to be the difference between "current" semantics and what you're using.

    Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Domain Nodelet?
    Node Status?
    node history
    Node Type: perlquestion [id://274633]
    Approved by Paladin
    help
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this?Last hourOther CB clients
    Other Users?
    Others imbibing at the Monastery: (6)
    As of 2024-03-28 20:13 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found