diff options
author | Daniel Friesel <derf@finalrewind.org> | 2015-03-18 21:32:13 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2015-03-18 21:32:13 +0100 |
commit | 02d822336f9d77eea4e4d9ae4954e76a782348c3 (patch) | |
tree | 1c5b09a24143c3952a79b38761724d73050ad0eb | |
parent | 274b8e8bf89bb8cbe29b987b9831827c84d94e75 (diff) |
sqlite-migration: slightly more fancy progress reports
-rwxr-xr-x | bin/sqlite-migration | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/bin/sqlite-migration b/bin/sqlite-migration index 86c7d66..2b2d235 100755 --- a/bin/sqlite-migration +++ b/bin/sqlite-migration @@ -17,6 +17,8 @@ our $VERSION = '0.00'; my $dbname = shift // 'dbdb'; +say "connecting to databases..."; + my $old_dbh = DBI->connect( "dbi:SQLite:dbname=iris.sqlite", q{}, q{} ); my $dbh = DBI->connect( "dbi:Pg:dbname=$dbname;host=localhost;port=5432", 'dbdb', $ENV{DBDB_PASSWORD} ); @@ -75,6 +77,7 @@ sub get_id { } } +say "checking tables..."; if ( not table_exists('lines') ) { $dbh->do( qq{ @@ -179,6 +182,8 @@ $timer->attr( max => $total, ); +print "copying data\n\n"; + my $i = 0; for my $row ( @{ $old_dbh->selectall_arrayref('select * from departures') } ) { @@ -188,10 +193,8 @@ for my $row ( @{ $old_dbh->selectall_arrayref('select * from departures') } ) { $train_no, $line_no, $platform ) = @{$row}; - if ( ( ++$i % 20 ) == 0 ) { - print $timer->report( - "\r\e[2Kmain table: %40b ETR %E", $i - ); + if ( ( ++$i % 100 ) == 0 ) { + print $timer->report( "\r\e[2Kmain table: %40b ETR %E", $i ); } my $station_id = get_id( 'station_codes', $station ); @@ -220,14 +223,13 @@ for my $row ( @{ $old_dbh->selectall_arrayref('select * from departures') } ) { } } +print "\n"; $timer->restart( min => 1, max => $total, ); for my $msg ( 1 .. 99 ) { - print $timer->report( - "\r\e[2Kmsg table : %40b ETR %E", $msg - ); + print $timer->report( "\r\e[2Kmsg table : %40b ETR %E", $msg ); for my $row ( @{ $old_dbh->selectall_arrayref("select * from msg_$msg") } ) { if ( not table_has_departure( "msg_$msg", @{$row} ) ) { @@ -235,6 +237,7 @@ for my $msg ( 1 .. 99 ) { } } } +print "\ndone!\n"; __END__ |