comparison create_quotedb.tcl @ 76:c4e10a75b868

Separate script for creating just one QuoteDB table.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 11 Sep 2011 18:09:25 +0300
parents create_spede_mn_tuksu.tcl@b083afd78d66
children 416642f28d1e
comparison
equal deleted inserted replaced
75:b083afd78d66 76:c4e10a75b868
1 #!/usr/bin/tclsh
2 # TCL script for creating (empty) QuoteDB SQLite3 database
3 #
4 # Written by Matti 'ccr' Hamalainen <ccr@tnsp.org>
5 # (C) Copyright 2011 Tecnic Software productions (TNSP)
6 #
7 package require sqlite3
8 source [file dirname [info script]]/util_convert.tcl
9
10 set db_list {quotedb}
11
12 ### Check commandline arguments
13 set db_str [join $db_list ", "]
14 if {$argc < 1} {
15 puts "Creates tables for QuoteDB in target SQLite3 file"
16 puts "Usage: $argv0 <output_sqlite3_db_file> \[-drop\]"
17 puts ""
18 puts "-drop option will drop any existing '$db_str' table of same name."
19 exit 0
20 }
21
22 set db_drop 0
23 set db_output [lindex $argv 0]
24 if {$argc >= 2 && [lindex $argv 1] == "-drop"} {
25 set db_drop 1
26 }
27
28 ### Open database
29 open_db $db_output
30
31 if {$db_drop} {
32 puts "WARNING! Dropping of old table(s) '$db_str' requested!"
33 puts "All data in those tables will be permanently lost!"
34
35 if {![confirm_yesno "Proceed"]} {
36 puts "Aborting procedure."
37 dbh close
38 exit 0
39 }
40
41 foreach i $db_list {
42 drop_table $i
43 }
44 }
45
46 puts "Creating tables $db_str ..."
47 foreach i $db_list {
48 create_table_quotes_votes $i 0
49 }
50
51 dbh close
52
53 puts "DONE."