summaryrefslogtreecommitdiff
path: root/src/postgres.sml
diff options
context:
space:
mode:
Diffstat (limited to 'src/postgres.sml')
-rw-r--r--src/postgres.sml6
1 files changed, 4 insertions, 2 deletions
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.\");",