# HG changeset patch # User Matti Hamalainen # Date 1315753765 -10800 # Node ID c4e10a75b8685a73069c09fda1c9d5c58c0822c3 # Parent b083afd78d665191f3e91333ddd2cdec6bb0f5e8 Separate script for creating just one QuoteDB table. diff -r b083afd78d66 -r c4e10a75b868 create_quotedb.tcl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/create_quotedb.tcl Sun Sep 11 18:09:25 2011 +0300 @@ -0,0 +1,53 @@ +#!/usr/bin/tclsh +# TCL script for creating (empty) QuoteDB SQLite3 database +# +# Written by Matti 'ccr' Hamalainen +# (C) Copyright 2011 Tecnic Software productions (TNSP) +# +package require sqlite3 +source [file dirname [info script]]/util_convert.tcl + +set db_list {quotedb} + +### Check commandline arguments +set db_str [join $db_list ", "] +if {$argc < 1} { + puts "Creates tables for QuoteDB in target SQLite3 file" + puts "Usage: $argv0 \[-drop\]" + puts "" + puts "-drop option will drop any existing '$db_str' table of same name." + exit 0 +} + +set db_drop 0 +set db_output [lindex $argv 0] +if {$argc >= 2 && [lindex $argv 1] == "-drop"} { + set db_drop 1 +} + +### Open database +open_db $db_output + +if {$db_drop} { + puts "WARNING! Dropping of old table(s) '$db_str' requested!" + puts "All data in those tables will be permanently lost!" + + if {![confirm_yesno "Proceed"]} { + puts "Aborting procedure." + dbh close + exit 0 + } + + foreach i $db_list { + drop_table $i + } +} + +puts "Creating tables $db_str ..." +foreach i $db_list { + create_table_quotes_votes $i 0 +} + +dbh close + +puts "DONE."