package ND::DB; use strict; use DBI; use DBD::Pg qw(:pg_types); require Exporter; our @ISA = qw/Exporter/; our @EXPORT = qw/DB/; sub DB { #Use domain sockets by default my $dbh = DBI->connect_cached("dbi:Pg:dbname=ndawn", "ndawn", "", {AutoCommit => 0, RaiseError => 1, PrintError => 0, pg_enable_utf8 => -1}); #Easy to also use /etc/postgresql/pg_services.conf #my $dbh = DBI->connect_cached("dbi:Pg:service=ndawn","", "", {AutoCommit => 0, RaiseError => 1, pg_enable_utf8 => 1}); $dbh->rollback; #Need to set autocommit after, to be able to rollback old incomplete transactions. $dbh->{AutoCommit} = 1; return $dbh; } 1;