On second thought, added PostgreSQL support. But official modules do not work with it yet.

This commit is contained in:
Elijah Perrault committed 2011-02-14 11:50:49 -07:00
1 parent 0bbf9ae5f1
commit 69c9ccb917
4 files changed
+29 -7

No files matched your search

+21
View File
@@ -219,6 +219,27 @@ given (lc((conf_get('database:format'))[0][0])) {
# # Connect to database.
# $DB = DBI->connect("dbi:CSV:f_dir=$Bin/../etc/".(conf_get('database:dir'))[0][0]) or err(2, 'Failed to connect to database!', 1);
#}
when ('pgsql') {
# PostgreSQL.
if ($ENFEAT !~ /pgsql/) { err(2, 'Auto not built with PostgreSQL support. Aborting.', 1); }
my @reqcval = qw(database:name database:host database:username database:password);
foreach (@reqcval) { if (!conf_get($_)) { err(2, "Missing required configuration value $_. Aborting.", 1); } }
# Import DBD::Pg.
require DBD::Pg;
# Connect to database.
if (conf_get('database:port')) {
# If a specific port was given, use it.
$DB = DBI->connect('dbi:Pg:db='.(conf_get('database:name'))[0][0].';host='.(conf_get('database:host'))[0][0].';port='.(conf_get('database:port'))[0][0],
(conf_get('database:username'))[0][0], (conf_get('database:password'))[0][0]) or err(2, 'Failed to connect to database!', 1);
}
else {
# We were not given a port, connect using PGPORT (usually 5432)
$DB = DBI->connect('dbi:Pg:db='.(conf_get('database:name'))[0][0].';host='.(conf_get('database:host'))[0][0],
(conf_get('database:username'))[0][0], (conf_get('database:password'))[0][0]) or err(2, 'Failed to connect to database!', 1);
}
}
# Unknown database format.
default { err(2, 'Unknown database format \''.lc((conf_get('database:format'))[0][0]).'\'. Aborting.', 1); }
}