Created
April 27, 2012 09:40
-
-
Save moritz/2507847 to your computer and use it in GitHub Desktop.
SQLite exercise for MiniDBI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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