diff src/luan/host/Util.luan @ 1416:db57d562c4bd

add Http.is_hosted
author Franklin Schmidt <fschmidt@gmail.com>
date Fri, 18 Oct 2019 15:06:32 -0600
parents 1979cff9aad2
children 732b5de211fc
line wrap: on
line diff
--- a/src/luan/host/Util.luan	Wed Oct 09 14:56:07 2019 -0600
+++ b/src/luan/host/Util.luan	Fri Oct 18 15:06:32 2019 -0600
@@ -76,13 +76,18 @@
 	if pg_admin == nil then
 		return
 	end
-	local db = database{
-		class = "org.postgresql.Driver"
-		url = "jdbc:postgresql://localhost:5432/"..domain
-		user = domain
-		password = password
-	}
+	local db = database(pg_admin)
+	local exists = db.query("select rolname from pg_roles where rolname=?",domain).results() ~= nil;
 	db.close()
+	if exists then
+		db = database{
+			class = "org.postgresql.Driver"
+			url = "jdbc:postgresql://localhost:5432/"..domain
+			user = domain
+			password = password
+		}
+		db.close()
+	end
 end
 
 return Util