Skip to content

Instantly share code, notes, and snippets.

@moritz
Created April 27, 2012 14:24
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/2509680 to your computer and use it in GitHub Desktop.
Save moritz/2509680 to your computer and use it in GitHub Desktop.
DBIish imaginary API example
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