gps-maintain.pl: a couple fixes.
Mucking around with my installation/port of gps for FreeBSD I made the following modifications to gps-maitain.pl.
The first patch adds/corrects SQLite support, it isn't the best solution but it gets the job done.
Modifications made against 1.002.
--- gps-maintain.pl.orig Mon Feb 14 13:27:37 2005
+++ gps-maintain.pl Mon Feb 14 13:46:26 2005
@@ -104,7 +104,19 @@
print "$key => $value\n";
}
}
-my $dbh = DBI->connect('DBI:'.$hash_ref->{dbtype}.':'.$hash_ref->{db_dbname},
+
+#
+# hack/fix for sqlite
+#
+my $db_driver = $hash_ref->{dbtype};
+my $db_name = $hash_ref->{db_dbname};
+
+if ( lc( $hash_ref->{dbtype} ) eq 'sqlite' ) {
+ $db_driver = 'SQLite'; # driver name is case sensitive
+ $db_name = $hash_ref->{db_sqlite_dbdir}.'/'.$hash_ref->{db_dbname};
+}
+
+my $dbh = DBI->connect('DBI:'.$db_driver.':'.$db_name,
$hash_ref->{db_username},
$hash_ref->{db_password} )
or die "Couldn't connect to database: " . DBI->errstr;
The following corrected a query against table 'triplets' which I belive was meant to be 'triplet'.
--- ./gps-maintain.pl.orig Thu Jan 20 20:43:06 2005
+++ gps-maintain.pl Mon Feb 14 13:48:27 2005
@@ -136,7 +136,7 @@
$sth->finish;
}
if( $delete == 1 ) {
- my $arows = $dbh->do('DELETE FROM triplets '.$sqlString)
+ my $arows = $dbh->do('DELETE FROM triplet '.$sqlString)
or die "Couldn't do statement: " . $dbh->errstr;
print STDOUT 'Deleted '.$arows." rows \n";
}
Seperate patches so you may pick and choose if you desire to use them.
On another note, if I were to completely rewirte those perl scripts (possibly using GetOpt) would it be worth it or desired?
- Log in to post comments
Re: gps-maintain.pl: a couple fixes.
First, thanks for the bugfixes. I have put them into my working copy. I am planning to make a bugfix release soon to spare people from having to read the Forum to find solutions to the problems.
Second, I would be grateful to see some proper perl code. I also think it would be worth it. The gps-maintain script could do things like generate statistics and hence improve the spam system (we were thinking of something that mrtg or munin can read).
So please go ahead and I will be happy to include your script(s) in gps.
Re: gps-maintain.pl: a couple fixes.
No problem.
I'll whip some stuff up and post it here when I am finished.
I had also sent some platform independant patches for the GNU configure scripts which handled the dlopen/dlsyn in libc for freebsd and the need for sys/sockets.h for AF_* defines to your email address before I had noticed that you prefer patches are posted here. I'm not sure if that email address is one you check often or if you did not receive the message. If you didn't get them let me know and I will re-post them here for you to take a look at.