DBD::MariaDB is a Perl Database Driver for MariaDB.
use DBI;
my $dsn = "DBI:MariaDB:database=$database;host=$hostname;port=$port";
my $dbh = DBI->connect($dsn, $user, $password);
my $sth = $dbh->prepare(
'SELECT id, first_name, last_name FROM authors WHERE last_name = ?'
) or die 'prepare statement failed: ' . $dbh->errstr();
$sth->execute('Eggers') or die 'execution failed: ' . $dbh->errstr();
print $sth->rows() . " rows found.\n";
while (my $ref = $sth->fetchrow_hashref()) {
print "Found a row: id = $ref->{'id'}, fn = $ref->{'first_name'}\n";
}
Top comments (0)