diff options
Diffstat (limited to 'db_procs.tcl')
-rwxr-xr-x | db_procs.tcl | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/db_procs.tcl b/db_procs.tcl new file mode 100755 index 0000000..728cb8d --- /dev/null +++ b/db_procs.tcl @@ -0,0 +1,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 |