summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugeniy Mikhailov <evgmik@gmail.com>2010-12-12 23:51:24 -0500
committerEugeniy Mikhailov <evgmik@gmail.com>2010-12-12 23:51:24 -0500
commitdcef98ac6b55bdd4dc41b6a5eff217e9b75e37ff (patch)
tree4127eba86d763baf0e9be673a9c429b2a37dbe7e
downloadGradeBook-dcef98ac6b55bdd4dc41b6a5eff217e9b75e37ff.tar.gz
GradeBook-dcef98ac6b55bdd4dc41b6a5eff217e9b75e37ff.zip
simple creation and output of sqlite DB
darcs-hash:20101213045124-067c0-087ed83de2c5ef44356cdd2a819e50262c838503.gz
-rwxr-xr-xdb_procs.tcl55
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