Skip to content

Instantly share code, notes, and snippets.

@masak
Created September 28, 2009 10:26
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 masak/195336 to your computer and use it in GitHub Desktop.
Save masak/195336 to your computer and use it in GitHub Desktop.
use v6;
use Squerl;
my $DB = Squerl.sqlite('example.db');
$DB.create_table: 'fruits',
'id' => 'primary_key',
'name' => 'String',
'qty' => 'Int',
;
my $fruits = $DB<fruits>;
my $i = 0;
for <apples pears oranges ninjas peaches papayas>
Z < 50 20 70 3 15 35> -> $name, $qty {
$fruits.insert($i++, $name, +$qty);
}
# those ninjas get in anywhere
$fruits.filter('name' => 'ninjas').delete;
# new shipment of pears
$fruits.filter('name' => 'pears').update('qty' => 40);
for $fruits.filter(sql_number('qty').gt(35)).llist {
say sprintf 'There are %d %s', .[2], .[1];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment