[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]
dave morgan <morgad@xxxxxxxxxxxxx> writes:
Thanks to Simon's hint I got trafstats running in the end, but it is total overkill for what I need. So I thought I would write my 2nd ever Perl Script. (machine is running Debian/Stable)
my $user = "david"; my $mydb = "ntp-stats"; my $dbh = DBI->connect("DBI:Pg:$mydb", $user, undef); $dbh->disconnect; but all I get is - DBI->connect(ntp-stats) failed: missing "=" after "ntp-stats" in connection info string at ./test4.pl line 8 Can't call method "disconnect" on an undefined value at ./test4.pl line 10.
You are using the wrong syntax, the perl DBI interface for Postgres is subtly different from the MySQL interface. Instead use: - my $dbh = DBI->connect("DBI:pg:dbname=$mydb", $user, undef) or die("Can't open db connection:$!\n");
how do you connect to a Postgresql database?
perldoc DBD::Pg (or indeed any other perldoc page) is your friend ;) -- James jamesk[at]homeric[dot]co[dot]uk 'First things first -- but not necessarily in that order' -- Dr Who -- The Mailing List for the Devon & Cornwall LUG Mail majordomo@xxxxxxxxxxxxx with "unsubscribe list" in the message body to unsubscribe. FAQ: www.dcglug.org.uk/linux_adm/list-faq.html