blob: 728cb8d0a2a16b531d55374cfa2f9eccadcaea16 (
plain)
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
44
45
46
47
48
49
50
51
52
53
54
55
|
#!/bin/sh
# FILE: "/mnt/light_huge_archive/home/evmik/src/my_src/GradeBook/db_procs.tcl"
# LAST MODIFICATION: "Sun, 12 Dec 2010 23:50:57 -0500 (evmik)"
# (C) 2010 by Eugeniy Mikhailov, <evgmik@gmail.com>
# $Id:$
# vim:set ft=tcl: \
exec tclsh "$0" "$@"
#load libtclsqlite3.so.0 Sqlite3
package require sqlite3
set dbfile "./testdb"
sqlite3 db $dbfile
proc createDB {db} {
db eval {CREATE TABLE t1(FirstName text, LastName text)}
db eval {INSERT INTO t1 VALUES('John','Lname1')}
db eval {INSERT INTO t1 VALUES('Ale','Lname2')}
db eval {INSERT INTO t1 VALUES('Dan','Lname3')}
#db1 eval {ALTER TABLE t1 ADD c int }
}
proc htmlDBout {db} {
#set x [db eval {SELECT * FROM t1 ORDER BY a}]
#puts $x
set show_header 1
puts "<table>"
db eval {SELECT * FROM t1 ORDER BY LastName} v {
puts "<tr>"
foreach index $v(*) {
if { $show_header } {
set show_header 0
foreach col $v(*) {
puts -nonewline "<td>$col</td>"
}
puts "</tr>"
puts "<tr>"
}
if { $index != "*" } {
puts -nonewline "<td>$v($index)</td>"
}
}
puts "</tr>"
}
puts "</table>"
}
#createDB db
htmlDBout db
|