1 USING: io io.files io.files.temp io.directories io.launcher
2 kernel namespaces prettyprint tools.test db.sqlite db sequences
3 continuations db.types db.tuples unicode.case ;
6 : db-path ( -- path ) "test.db" temp-file ;
7 : test.db ( -- sqlite-db ) db-path <sqlite-db> ;
9 [ ] [ [ db-path delete-file ] ignore-errors ] unit-test
13 "create table person (name varchar(30), country varchar(30))" sql-command
14 "insert into person values('John', 'America')" sql-command
15 "insert into person values('Jane', 'New Zealand')" sql-command
20 [ { { "John" "America" } { "Jane" "New Zealand" } } ] [
22 "select * from person" sql-query
26 [ { { "1" "John" "America" } { "2" "Jane" "New Zealand" } } ]
27 [ test.db [ "select rowid, * from person" sql-query ] with-db ] unit-test
31 "insert into person(name, country) values('Jimmy', 'Canada')"
38 { "1" "John" "America" }
39 { "2" "Jane" "New Zealand" }
40 { "3" "Jimmy" "Canada" }
42 ] [ test.db [ "select rowid, * from person" sql-query ] with-db ] unit-test
47 "insert into person(name, country) values('Jose', 'Mexico')" sql-command
48 "insert into person(name, country) values('Jose', 'Mexico')" sql-command
56 "select * from person" sql-query length
63 "insert into person(name, country) values('Jose', 'Mexico')"
65 "insert into person(name, country) values('Jose', 'Mexico')"
73 "select * from person" sql-query length