Created
September 28, 2009 10:26
-
-
Save masak/195336 to your computer and use it in GitHub Desktop.
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 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