Diff

util/sql.lua @ 7308:397f45107795

Merge 0.10->trunk
author Kim Alvefur <zash@zash.se>
date Mon, 21 Mar 2016 14:52:43 +0100
parent 7306:98c4c3a2b536
child 7312:b4e99602ae75
line wrap: on
line diff
--- a/util/sql.lua	Mon Mar 21 12:10:10 2016 +0100
+++ b/util/sql.lua	Mon Mar 21 14:52:43 2016 +0100
@@ -102,11 +102,12 @@
 	local params = self.params;
 	assert(params.driver, "no driver")
 	log("debug", "Connecting to [%s] %s...", params.driver, params.database);
-	local dbh, err = DBI.Connect(
+	local ok, dbh, err = pcall(DBI.Connect,
 		params.driver, params.database,
 		params.username, params.password,
 		params.host, params.port
 	);
+	if not ok then return ok, dbh; end
 	if not dbh then return nil, err; end
 	dbh:autocommit(false); -- don't commit automatically
 	self.conn = dbh;