From f926b6418df3e6b835f8bc5b7c44906c9742a085 Mon Sep 17 00:00:00 2001 From: Austin Seipp Date: Fri, 23 Sep 2011 23:11:59 -0500 Subject: Add an URWEB_PQ_CON environment variable, which overrides the PostgreSQL connection string. --- src/postgres.sml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/postgres.sml') diff --git a/src/postgres.sml b/src/postgres.sml index 9707096f..a66c85d9 100644 --- a/src/postgres.sml +++ b/src/postgres.sml @@ -476,9 +476,11 @@ fun init {dbstring, prepared = ss, tables, views, sequences} = string "static void uw_db_init(uw_context ctx) {", newline, - string "PGconn *conn = PQconnectdb(\"", + string "char *env_db_str = getenv(\"URWEB_PQ_CON\");", + newline, + string "PGconn *conn = PQconnectdb(env_db_str == NULL ? \"", string (String.toCString dbstring), - string "\");", + string "\" : env_db_str);", newline, string "if (conn == NULL) uw_error(ctx, FATAL, ", string "\"libpq can't allocate a connection.\");", -- cgit v1.2.3