Created
April 27, 2012 14:24
-
-
Save moritz/2509680 to your computer and use it in GitHub Desktop.
DBIish imaginary API example
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 DBIish; | |
# RaiseError is default | |
my $dbh = DBIish.connect('SQLite', :dbname<db.sqlite3>); | |
my $stmt = $dbh.prepare('SELECT (col1, col2) FROM t WHERE col3 = ?'); | |
$stmt.execute(42); | |
# lazy iteration | |
for $stmt.all-rows -> @row { | |
say @row.join(', '); | |
} | |
# p6ish interface | |
# no distinction between fetchrow_array and fetchrow_arrayref | |
$stmt.execute(23); | |
while $stmt.fetchrow -> @row { | |
say @row.join(', '); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment