I think this works nicely:
sqlite3 db ${database} -create False -readonly True
set fields {}
foreach field [db eval "SELECT * FROM (${query}) LIMIT 1"] {
lappend fields ""
}
set divider [string map {" " - | +} [format ${formatStr} {*}${fields}]]
puts ${divider}
db eval ${query} values {
set fields {}
foreach field ${values(*)} {
lappend fields $values($field)
}
puts [format ${formatStr} {*}${fields}]
}
puts ${divider}
db close
I probably should change db to something else. In this way the risk of
a conflict is quite high.
If I would call the proc SQLiteQueryToTable, I could use:
sqlite3 SQLiteQueryToTable ${database} -create False -readonly True
Would that be a good idea?