Mercurial > hg > egg-tcls
changeset 256:f3906e583798
Remove conversion scripts.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 23 Jan 2015 09:21:25 +0200 |
parents | 4d4f3defe3ca |
children | 4abc5366866c |
files | convert_feeds_db.tcl convert_spede_mn_tuksu.tcl convert_urllog_db.tcl |
diffstat | 3 files changed, 0 insertions(+), 257 deletions(-) [+] |
line wrap: on
line diff
--- a/convert_feeds_db.tcl Tue Jan 20 00:02:35 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -#!/usr/bin/tclsh -# TCL script for converting Feed 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 [file dirname [info script]]/util_convert.tcl - -### Check commandline arguments -if {$argc != 2} { - puts "Usage: $argv0 <input_flat_file_db> <output_sqlite_db_file>" - exit 0 -} - -set db_input [lindex $argv 0] -set db_output [lindex $argv 1] - -### Ask for confirmation -puts "Conversion of '$db_input' to SQLite database '$db_output'." -puts "NOTICE! This WILL destroy the current data in the target database!" - -if {![confirm_yesno "Proceed"]} { - exit 0 -} - -### Open flatfile for reading -if {[catch {set fd [open $db_input r]} uerrmsg]} { - puts "Could not open file '$db_input' for reading: $uerrmsg" - exit 1 -} - -### Open SQLite database, drop old tables, create new -open_db $db_output - -drop_table_feeds -create_table_feeds - - -### Convert data -puts -nonewline "Converting database, please wait " -set nline 0 -seek $fd 0 start - -while {![eof $fd]} { - incr nline - gets $fd uline - set items [split $uline "½"] - if {[llength $items] == 4} { - set sql "INSERT INTO feeds (feed,utime,url,title) VALUES ('[lescape $items 1]', [lindex $items 0], '[lescape $items 2]', '[lescape $items 3]')" - if {[catch {dbh eval $sql} uerrmsg]} { - puts "\nError ($nline): $uerrmsg on:\n$sql" - exit 15 - } - } - - if {[expr $nline % 10] == 1} { - puts -nonewline "." - flush stdout - } -} - -dbh close -close $fd - -puts "DONE."
--- a/convert_spede_mn_tuksu.tcl Tue Jan 20 00:02:35 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,66 +0,0 @@ -#!/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 [file dirname [info script]]/util_convert.tcl - -### Check commandline arguments -if {$argc != 3} { - puts "Usage: $argv0 <input_flat_file_db> <output_sqlite_db_file> <table_name>" - exit 0 -} - -set db_input [lindex $argv 0] -set db_output [lindex $argv 1] -set db_table [lindex $argv 2] - -### Ask for confirmation -puts "Conversion of '$db_input' to SQLite database '$db_output', to table '$db_table'." -puts "NOTICE! This WILL destroy the current data in table '$db_table'!" - -if {![confirm_yesno "Proceed"]} { - exit 0 -} - -### Open flatfile for reading -if {[catch {set fd [open $db_input r]} uerrmsg]} { - puts "Could not open file '$db_input' for reading: $uerrmsg" - exit 1 -} - -### Open SQLite database, drop old tables, create new -open_db $db_output -drop_table $db_table -create_table_quotes_votes $db_table 1 - -### Convert data -puts -nonewline "Converting database, please wait " -set nline 0 -seek $fd 0 start -while {![eof $fd]} { - incr nline - set line [gets $fd] - if {$line != ""} { - set items [split $line "|"] - set host [lindex $items 3] - set uid [lindex $items 4] - set sql "INSERT INTO $db_table (id,utime,utext,user,host,chan) VALUES ([lindex $items 0], [lindex $items 2], '[lescape $items 1]', '[lescape $items 3]', '[lescape $items 4]', '[lescape $items 5]')" - if {[catch {dbh eval $sql} uerrmsg]} { - puts "\nError ($nline): $uerrmsg on:\n$sql" - exit 15 - } - } - if {[expr $nline % 10] == 1} { - puts -nonewline "." - flush stdout - } -} - -dbh close -close $fd - -puts "DONE."
--- a/convert_urllog_db.tcl Tue Jan 20 00:02:35 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,124 +0,0 @@ -#!/usr/bin/tclsh -# TCL script for converting URLLog v1.x flat file -# format database to SQLite3 database. -# -# Written by Matti 'ccr' Hamalainen <ccr@tnsp.org> -# (C) Copyright 2011 Tecnic Software productions (TNSP) -# -package require sqlite3 -source [file dirname [info script]]/util_convert.tcl - -### Check commandline arguments -if {$argc != 2} { - puts "Usage: $argv0 <input_flat_file_db> <output_sqlite_db_file>" - exit 0 -} - -set db_input [lindex $argv 0] -set db_output [lindex $argv 1] -set db_table "urls" - -### Ask for confirmation -puts "Conversion of '$db_input' to SQLite database '$db_output', to table '$db_table'." -puts "NOTICE! This WILL destroy the current data in table '$db_table'!" - -if {![confirm_yesno "Proceed"]} { - exit 0 -} - -### Open flatfile for reading -if {[catch {set fd [open $db_input r]} uerrmsg]} { - puts "Could not open '$db_input' for reading: $uerrmsg" - exit 1 -} - -### Open SQLite database, drop old table, create new -open_db $db_output -drop_table "urls" -create_table_urls - -### Detect URL database version -puts -nonewline "Detecting database version: " -set nline 0 -set minentries 9999 -set maxentries 0 -while {![eof $fd]} { - incr nline - set line [gets $fd] - if {$line != ""} { - set items [split $line " "] - set tmp [llength $items] - if {$tmp > $maxentries} { set maxentries $tmp } - if {$tmp < $minentries} { set minentries $tmp } - } -} - -if {$maxentries != 5 || $maxentries != $minentries} { - puts "old / variable" -} else { - puts "new" -} - -### Show some information -puts "Database contains $nline records, with $minentries / $maxentries entries." - -### Begin conversion -puts -nonewline "Converting database, please wait ... round #1 " -set nline 0 -seek $fd 0 start -while {![eof $fd]} { - incr nline - set line [gets $fd] - set items [split $line " "] - if {$line != ""} { - set host [lindex $items 3] - if {[regexp {^\((.+)\)$} $host ures uhost]} { - set host $uhost - } - set uid [lindex $items 4] - if {$uid != ""} { - set sql "INSERT INTO $db_table (id,utime,url,user,host) VALUES ($uid, [lindex $items 1], '[lescape $items 0]', '[lescape $items 2]', '[escape $host]')" - if {[catch {dbh eval $sql} uerrmsg]} { - puts "\nError ($nline): $uerrmsg on:\n$sql" - exit 15 - } - } - } - if {[expr $nline % 10] == 1} { - puts -nonewline "." - flush stdout - } -} -puts "OK" - -puts -nonewline "\nRound #2 " -set nline 0 -seek $fd 0 start -while {![eof $fd]} { - incr nline - set line [gets $fd] - set items [split $line " "] - if {$line != ""} { - set host [lindex $items 3] - if {[regexp {^\((.+)\)$} $host ures uhost]} { - set host $uhost - } - set uid [lindex $items 4] - if {$uid == ""} { - set sql "INSERT INTO $db_table (utime,url,user,host) VALUES ([lindex $items 1], '[lescape $items 0]', '[lescape $items 2]', '[escape $host]')" - if {[catch {dbh eval $sql} uerrmsg]} { - puts "\nError ($nline): $uerrmsg on:\n$sql" - exit 15 - } - } - } - if {[expr $nline % 10] == 1} { - puts -nonewline "." - flush stdout - } -} - -dbh close -close $fd - -puts "DONE."