Name

errstr( )

Synopsis

$handle->errstr( )

This returns any error messages from the last driver method called.

 . . .
my $dbh = DBI->connect('DBI:mysql:bookstore:localhost',
                       'username","password')
          || die 'Could not connect to database: '
          . DBI->errstr;

The error message given in the die statement is joined to the DBI error message.

Get MySQL in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.