dump part of communication parameters
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 16 Nov 2014 15:40:27 +0000 (16:40 +0100)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 16 Nov 2014 15:40:27 +0000 (16:40 +0100)
db3-dump.pl [new file with mode: 0755]

diff --git a/db3-dump.pl b/db3-dump.pl
new file mode 100755 (executable)
index 0000000..44d44de
--- /dev/null
@@ -0,0 +1,45 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+
+use DBI;
+use Data::Dump qw(dump);
+
+my $dbh = DBI->connect ("dbi:CSV:", "", "", {
+       f_dir => "./db3",
+       f_ext => ".csv",
+});
+
+sub lookup {
+       my $sql = shift;
+       my $data;
+
+       my $sth = $dbh->prepare( $sql );
+       $sth->execute;
+
+       while( my $row = $sth->fetchrow_arrayref ) {
+               $data->{ $row->[0] } = $row->[1];
+       }
+
+       return $data;
+}
+
+my $text = lookup( qq{
+select Id, texteEN from "SymbolNames"
+});
+
+#warn "# text = ",dump( $text );
+
+my $types = lookup( qq{
+select TypeId, TypeName from "DataTyps"
+});
+
+my $sth = $dbh->prepare( qq{
+select * from "ComuInfos"
+order by adresse
+});
+$sth->execute;
+
+while( my $row = $sth->fetchrow_hashref ) {
+       printf "%02x %-25s %s\n", $row->{adresse}, $types->{ $row->{typid} }, $text->{ $row->{id} };
+}