forked from covscript/covscript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sqlite.csc
43 lines (43 loc) · 962 Bytes
/
sqlite.csc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import sqlite_ext
import sqlite
function print_result(stmt)
for i=0,i<stmt.column_count(),++i
system.out.print(stmt.column_decltype(i)+"\t")
system.out.print(stmt.column_name(i))
system.out.print("=\t")
switch stmt.column_type(i)
case sqlite.integer
system.out.println(stmt.column_integer(i))
end
case sqlite.real
system.out.println(stmt.column_real(i))
end
case sqlite.text
system.out.println(stmt.column_text(i))
end
end
end
end
var db=sqlite.open("test.db")
var stmt=db.prepare("select * from test where b=?")
stmt.bind_real(1,3.14)
stmt.exec()
print_result(stmt)
stmt.reset()
stmt.clear_bindings()
stmt.bind_real(1,6.28)
stmt.exec()
print_result(stmt)
stmt=null
loop
system.out.print(">>")
var result=sqlite_ext.exec(db,system.in.getline())
foreach row:result
foreach it:row
system.out.print(it.type+"\t")
system.out.print(it.name)
system.out.print("=\t")
system.out.println(it.data)
end
end
end