Version 7 of tcl sqlite examples

Updated 2009-11-20 18:00:33 by nscerqueira

Some examples of tcl and sqlite usage:

NOTE: the name of the database is opendb

  • Retrieve the names of the tables stored in a sqlite database:
   set tableNames [opendb eval {SELECT tbl_name FROM sqlite_master}]
  • Retrieve the names of the columns tored in a sqlite database(variable columnName):
   opendb eval "SELECT * FROM $tableName LIMIT 1" x {set columnName $x(*)} 

jnc You can also use the PRAGMA statement table_info(table_name) to retrieve column information. See http://sqlite.org/pragma.html for a list of all PRAGMA statements.

  • Retrieve the row data from a table
opendb eval "Select * FROM $i" values {set rowValues $values(*)} 
set rowList ""
foreach a $rowValues {set rowList "$rowList        $values($a)"}

puts $rowList