Skip to content

Instantly share code, notes, and snippets.

@davorg
Last active March 15, 2021 11:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davorg/333423320118ccf45dcb47cf30968b9f to your computer and use it in GitHub Desktop.
Save davorg/333423320118ccf45dcb47cf30968b9f to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use strict;
use warnings;
use feature 'say';
use DBI;
my $dbh = DBI->connect(
"DBI:mysql:database=test",
'xxx', 'xxx',
{ RaiseWarn => 1, PrintWarn => 1 },
)
or die;
$dbh->do('set @@SQL_MODE = ""');
$dbh->do('INSERT INTO example (tooshort) values ("12345")');
my $sth = $dbh->prepare('SHOW WARNINGS');
$sth->execute;
while (my $data = $sth->fetch) {
say join ' | ', @$data;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment