Posted to tcl by evilotto at Mon Oct 14 18:52:05 GMT 2013view raw
- #!/usr/bin/env tclsh8.6
- package require sqlite3
- set fsl [lindex $argv 0]
- set search [lindex $argv 1]
- sqlite db $fsl
- puts "creating index"
- db eval {
- create virtual table if not exists ticket_search using fts4(tkt_uuid, subsystem, title, comment);
- }
- puts "indexing ..."
- db eval {
- insert into ticket_search
- select tkt_uuid, subsystem, title, comment from ticket
- where tkt_uuid not in (select tkt_uuid from ticket_search)
- }
- puts "scanning"
- puts [format "%12.12s %-15.15s %s" "Ticket UUID" "Subsystem" "Title"]
- db eval {
- select tkt_uuid, subsystem, title from ticket_search where
- ticket_search match $search
- } row {
- puts [format "%12.12s %-15.15s %s" $row(tkt_uuid) $row(subsystem) $row(title)]
- }