hydra-queue-runner: Handle $HYDRA_DBI

This commit is contained in:
Eelco Dolstra 2015-06-17 22:11:01 +02:00
parent 4d9c74335d
commit ec8e8edc86

View file

@ -60,7 +60,16 @@ typedef enum {
struct Connection : pqxx::connection
{
Connection() : pqxx::connection("dbname=hydra") { };
Connection() : pqxx::connection(getFlags()) { };
string getFlags()
{
string s = getEnv("HYDRA_DBI", "dbi:Pg:dbname=hydra;");
string prefix = "dbi:Pg:";
if (string(s, 0, prefix.size()) != prefix)
throw Error("$HYDRA_DBI does not denote a PostgreSQL database");
return concatStringsSep(" ", tokenizeString<Strings>(string(s, prefix.size()), ";"));
}
};