Skip to content

Instantly share code, notes, and snippets.

@moritz
Created April 27, 2012 09:40
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 moritz/2507847 to your computer and use it in GitHub Desktop.
Save moritz/2507847 to your computer and use it in GitHub Desktop.
SQLite exercise for MiniDBI
use v6;
use MiniDBI;
my $dbh = MiniDBI.connect('SQLite', :dbname<test.sqlite3>, :RaiseError);
$dbh.do('DROP TABLE IF EXISTS t');
$dbh.do('CREATE TABLE t(x INTEGER PRIMARY KEY ASC, y, z)');
my $sth = $dbh.prepare('INSERT INTO t (y, z) VALUES (?, ?)');
for <a b c d e f g h> -> $a, $b {
$sth.execute($a, $b);
}
$sth.finish;
$sth = $dbh.prepare('SELECT x, y, z FROM t');
$sth.execute;
while my @row = $sth.fetchrow_array {
say @row.join(', ');
}
$sth.finish;
# CONTROL {
# default { say .backtrace.full }
# }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment