Add Postgresql support. pgsql
authorSebastian Fiedler <fiedler@schlittermann.de>
Thu, 12 Oct 2017 12:32:14 +0200
branchpgsql
changeset 111 1898ce7c3fd3
parent 110 86504771a173
child 112 7cf7fea55c2b
Add Postgresql support.
Makefile
config.pm
debian/changelog
debian/docs
log.pl
--- a/Makefile	Fri Apr 28 09:28:28 2017 +0200
+++ b/Makefile	Thu Oct 12 12:32:14 2017 +0200
@@ -19,6 +19,7 @@
 
 	install -d -m 0755 $(DESTDIR)/usr/share/perl5/Logbuch
 	install -m 0644 Logbuch/HG.pm $(DESTDIR)/usr/share/perl5/Logbuch/
+	dh_installdocs
 
 clean:
 	-rm -f $(bin_SCRIPTS)
--- a/config.pm	Fri Apr 28 09:28:28 2017 +0200
+++ b/config.pm	Thu Oct 12 12:32:14 2017 +0200
@@ -8,6 +8,14 @@
 
 # @notify_dirs = qw(/etc);
 
+# DB config
 $db = 1;
 
-1;
+# for MySQL use
+# DBI:mysql:logbuch:localhost
+# for Postgres (socket connection) use
+# DBI:Pg:dbname=logbuch;port=5432
+$dbDSN   = "";
+$dbUser  = "logbuch";
+$dbPass  = "changeit";
+
--- a/debian/changelog	Fri Apr 28 09:28:28 2017 +0200
+++ b/debian/changelog	Thu Oct 12 12:32:14 2017 +0200
@@ -1,3 +1,10 @@
+logbuch (0.49+num2) stable oldstable; urgency=medium
+
+  * Non-maintainer upload.
+  * Support for Postgres.
+
+ -- Sebastian Fiedler <fiedler@schlittermann.de>  Thu, 12 Oct 2017 12:17:26 +0200
+
 logbuch (0.49+nmu1) stable oldstable; urgency=medium
 
   * Non-maintainer upload.
--- a/debian/docs	Fri Apr 28 09:28:28 2017 +0200
+++ b/debian/docs	Thu Oct 12 12:32:14 2017 +0200
@@ -0,0 +1,1 @@
+docs/*
\ No newline at end of file
--- a/log.pl	Fri Apr 28 09:28:28 2017 +0200
+++ b/log.pl	Thu Oct 12 12:32:14 2017 +0200
@@ -56,9 +56,9 @@
 
 my $ME = basename $0;
 
-my $DSN  = "DBI:mysql:logbuch:pu.schlittermann.de";
-my $USER = "logbuch";
-my $PW   = "HIDDEN";
+my $DSN  = $config::dbDSN;
+my $USER = $config::dbUser;
+my $PW   = $config::dbPass;
 
 my $EDITOR   = $ENV{VISUAL} || $ENV{EDITOR} || "vim";
 my $MAGIC    = "#--- all changes below are ignored ---#\n";
@@ -252,7 +252,7 @@
 
         if ($opt_db and $Dbh) {
             my $sth = $Dbh->prepare("
-		    INSERT INTO log (host, date, user, mailto, text)
+		    INSERT INTO log (host, date, \"user\", mailto, text)
 		    VALUES(?, now(), ?, ?, ?)");
             $sth->execute(full_hostname(), $user, $mailto, $text);
             print STDERR "Database entry inserted\n";