summaryrefslogtreecommitdiff
path: root/python/skytools/scripting.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/skytools/scripting.py')
-rw-r--r--python/skytools/scripting.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/python/skytools/scripting.py b/python/skytools/scripting.py
index a8baffd6..3d175429 100644
--- a/python/skytools/scripting.py
+++ b/python/skytools/scripting.py
@@ -659,10 +659,15 @@ class DBScript(BaseScript):
"""
max_age = self.cf.getint('connection_lifetime', DEF_CONN_AGE)
+
if not cache:
cache = dbname
if cache in self.db_cache:
+ if connstr is None:
+ connstr = self.cf.get(dbname, '')
dbc = self.db_cache[cache]
+ if connstr:
+ dbc.check_connstr(connstr)
else:
if not connstr:
connstr = self.cf.get(dbname)
@@ -950,6 +955,12 @@ class DBCachedConn(object):
conn.close()
except: pass
+ def check_connstr(self, connstr):
+ """Drop connection if connect string has changed.
+ """
+ if self.loc != connstr:
+ self.reset()
+