Posted to tcl by evilotto at Mon Oct 14 18:52:05 GMT 2013view raw

  1. #!/usr/bin/env tclsh8.6
  2.  
  3. package require sqlite3
  4.  
  5. set fsl [lindex $argv 0]
  6. set search [lindex $argv 1]
  7.  
  8. sqlite db $fsl
  9.  
  10. puts "creating index"
  11. db eval {
  12. create virtual table if not exists ticket_search using fts4(tkt_uuid, subsystem, title, comment);
  13. }
  14. puts "indexing ..."
  15. db eval {
  16. insert into ticket_search
  17. select tkt_uuid, subsystem, title, comment from ticket
  18. where tkt_uuid not in (select tkt_uuid from ticket_search)
  19. }
  20. puts "scanning"
  21.  
  22. puts [format "%12.12s %-15.15s %s" "Ticket UUID" "Subsystem" "Title"]
  23.  
  24. db eval {
  25. select tkt_uuid, subsystem, title from ticket_search where
  26. ticket_search match $search
  27. } row {
  28. puts [format "%12.12s %-15.15s %s" $row(tkt_uuid) $row(subsystem) $row(title)]
  29. }
  30.