Mercurial > hg > egg-tcls
changeset 32:96fdf24afd9c
Add scripts for *creating* empty URLLog and Spede/MN/Tuksu databases.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 06 Sep 2011 16:32:51 +0300 |
parents | 1ddfada536ff |
children | 8a6bfcf1f57b |
files | create_spede_mn_tuksu.tcl create_urllog_db.tcl |
diffstat | 2 files changed, 99 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/create_spede_mn_tuksu.tcl Tue Sep 06 16:32:51 2011 +0300 @@ -0,0 +1,54 @@ +#!/usr/bin/tclsh +# TCL script for converting Spede, MN and Tuksu databases from +# flatfile format to SQLite3 database. +# +# Written by Matti 'ccr' Hamalainen <ccr@tnsp.org> +# (C) Copyright 2011 Tecnic Software productions (TNSP) +# +package require sqlite3 +source util_convert.tcl + +set db_list {spededb tuksudb mndb} + +### Check commandline arguments +set db_str [join $db_list ", "] +if {$argc < 1} { + puts "Creates tables for $db_str target SQLite3 file" + puts "Usage: $argv0 <output_sqlite3_db_file> \[-drop\]" + puts "" + puts "-drop option will drop any existing tables 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 tables $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 +} + +dbh close + +puts "DONE."
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/create_urllog_db.tcl Tue Sep 06 16:32:51 2011 +0300 @@ -0,0 +1,45 @@ +#!/usr/bin/tclsh +# TCL script for creating (empty) URLLog SQLite3 database +# +# Written by Matti 'ccr' Hamalainen <ccr@tnsp.org> +# (C) Copyright 2011 Tecnic Software productions (TNSP) +# +package require sqlite3 +source util_convert.tcl + +### Check commandline arguments +if {$argc < 1} { + puts "Creates tables for URLLog target SQLite3 file" + puts "Usage: $argv0 <output_sqlite3_db_file> \[-drop\]" + puts "" + puts "-drop option will drop any existing URLLog tables." + 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 old tables URLLog requested!" + puts "All data in those tables will be permanently lost!" + + if {![confirm_yesno "Proceed"]} { + puts "Aborting procedure." + dbh close + exit 0 + } + + drop_table "urls" +} + +create_table_urls + +dbh close + +puts "DONE."