1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Copyright 2013 Guillaume Auger <jeho@resist.ca>
4 # Copyright 2013-2014 Alexis Laferrière <alexis.laf@xymus.net>
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
20 var path
= "test_nity.db"
21 #alt1#path = "/../invalid_path.db"
22 if path
.file_exists
then path
.file_delete
24 var db
= new Sqlite3DB.open
(path
)
25 assert db
.is_open
else print db
.error
or else "no error?"
27 assert db
.create_table
("IF NOT EXISTS users (uname TEXT PRIMARY KEY, pass TEXT NOT NULL, activated INTEGER, perc FLOAT)") else
28 print db
.error
or else "no error?"
31 assert db
.insert
("INTO users VALUES('Bob', 'zzz', 1, 77.7)") else
32 print db
.error
or else "no error?"
35 assert db
.insert
("INTO users VALUES('Guillaume', 'xxx', 1, 88.8)") else
36 print db
.error
or else "no error?"
39 #alt2#assert db.insert("INTO notable VALUES('Alexis', 'asdf', 2, 99.9)") else
40 #alt2# print db.error or else "no error?"
43 for row
in db
.select
("* FROM users") do
46 printn
"{row[0].name}: "
49 printn
"{row[1].name}: "
50 var val
= row
[1].value
54 printn
"{row[2].name}: "
57 printn
"{row[3].name}: "