diff options
author | Marko Kreen | 2013-03-21 21:16:07 +0000 |
---|---|---|
committer | Marko Kreen | 2013-03-22 08:50:23 +0000 |
commit | 1d535a88c28f9a8ff8b6977340a3e4c0b553f92c (patch) | |
tree | a8ec77fb2fcfc5833af08f88e88652ef7dbbf891 /python/skytools/scripting.py | |
parent | 5868d74d1ba77f9fae4bbbdd668b1e4e4f45f867 (diff) |
londiste: connection profiles
Way to add extra connect string parameters for non-config
connection strings (public node locations).
Diffstat (limited to 'python/skytools/scripting.py')
-rw-r--r-- | python/skytools/scripting.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/python/skytools/scripting.py b/python/skytools/scripting.py index e4efdf00..df0a2ea2 100644 --- a/python/skytools/scripting.py +++ b/python/skytools/scripting.py @@ -697,7 +697,7 @@ class DBScript(BaseScript): self._db_defaults[dbname] = kwargs def get_database(self, dbname, autocommit = 0, isolation_level = -1, - cache = None, connstr = None): + cache = None, connstr = None, profile = None): """Load cached database connection. User must not store it permanently somewhere, @@ -727,12 +727,20 @@ class DBScript(BaseScript): if cache in self.db_cache: if connstr is None: connstr = self.cf.get(dbname, '') + if profile: + extra = self.cf.get("%s_extra_connstr" % profile, '') + if extra: + connstr += ' ' + extra dbc = self.db_cache[cache] if connstr: dbc.check_connstr(connstr) else: if not connstr: connstr = self.cf.get(dbname) + if profile: + extra = self.cf.get("%s_extra_connstr" % profile, '') + if extra: + connstr += ' ' + extra # connstr might contain password, it is not a good idea to log it filtered_connstr = connstr |