Last active
April 8, 2022 13:01
-
-
Save massa/6507d1fecb435abb0a397c935b5b2871 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/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 = "Julieta", age = 27'); | |
$db.execute('insert into teste01 set id = 7, nome = "Pepa", 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(:array-of-hash) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment