Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save massa/6dda3487a122d70f70b371395231c956 to your computer and use it in GitHub Desktop.
Save massa/6dda3487a122d70f70b371395231c956 to your computer and use it in GitHub Desktop.
#!/usr/bin/env raku
use v6.d;
use DBIish;
use YAMLish;
my %cred = load-yaml("%*ENV<HOME>/.creds.yaml".IO.slurp)<gabinete>;
my $db = DBIish.connect: 'mysql', :host<127.0.0.1>, :3306port, |%cred;
$db.execute('drop database if exists testedb');
$db.execute('create database if not exists testedb');
$db.execute('use testedb');
$db.execute('drop table if exists teste01');
$db.execute(q:to/END/);
create table if not exists teste01 (
id INTEGER PRIMARY KEY auto_increment,
nome varchar(200),
age integer,
obs blob(2000)
)
END
$db.execute('insert into teste01 set nome = "Bruno", age = 27, obs = "We dont talk about Bruno"');
$db.execute('insert into teste01 set id = 5, nome = "Pepa", age = 27, obs = "Controls the weather"');
$db.execute('insert into teste01 set nome = "Marisol"');
with $db.execute('select id, nome, age, obs from teste01') {
say save-yaml .allrows(:arry-of-hash)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment