Signed-off-by: Mark Hymers <mhy@debian.org>
if mode == 'db':
connstr = ""
if mode == 'db':
connstr = ""
+ if cnf.has_key("DB::Service"):
+ # Service mode
+ connstr = "postgresql://service=%s" % cnf["DB::Service"]
+ elif cnf.has_key("DB::Host"):
# TCP/IP
connstr = "postgres://%s" % cnf["DB::Host"]
# TCP/IP
connstr = "postgres://%s" % cnf["DB::Host"]
- if cnf["DB::Port"] and cnf["DB::Port"] != "-1":
+ if cnf.has_key("DB::Port") and cnf["DB::Port"] != "-1":
connstr += ":%s" % cnf["DB::Port"]
connstr += "/%s" % cnf["DB::Name"]
else:
connstr += ":%s" % cnf["DB::Port"]
connstr += "/%s" % cnf["DB::Name"]
else:
connstr += "?port=%s" % cnf["DB::Port"]
print connstr
elif mode == 'db-shell':
connstr += "?port=%s" % cnf["DB::Port"]
print connstr
elif mode == 'db-shell':
- e = ['PGDATABASE']
- print "PGDATABASE=%s" % cnf["DB::Name"]
- if cnf["DB::Host"]:
+ if cnf.has_key("DB::Service"):
+ e.append('PGSERVICE')
+ print "PGSERVICE=%s" % cnf["DB::Service"]
+ if cnf.has_key("DB::Name"):
+ e.append('PGDATABASE')
+ print "PGDATABASE=%s" % cnf["DB::Name"]
+ if cnf.has_key("DB::Host"):
print "PGHOST=%s" % cnf["DB::Host"]
e.append('PGHOST')
print "PGHOST=%s" % cnf["DB::Host"]
e.append('PGHOST')
- if cnf["DB::Port"] and cnf["DB::Port"] != "-1":
+ if cnf.has_key("DB::Port") and cnf["DB::Port"] != "-1":
print "PGPORT=%s" % cnf["DB::Port"]
e.append('PGPORT')
print "export " + " ".join(e)
print "PGPORT=%s" % cnf["DB::Port"]
e.append('PGPORT')
print "export " + " ".join(e)
def __createconn(self):
from config import Config
cnf = Config()
def __createconn(self):
from config import Config
cnf = Config()
+ if cnf.has_key("DB::Service"):
connstr = "postgresql://service=%s" % cnf["DB::Service"]
connstr = "postgresql://service=%s" % cnf["DB::Service"]
+ elif cnf.has_key("DB::Host"):
# TCP/IP
connstr = "postgresql://%s" % cnf["DB::Host"]
# TCP/IP
connstr = "postgresql://%s" % cnf["DB::Host"]
- if cnf["DB::Port"] and cnf["DB::Port"] != "-1":
+ if cnf.has_key("DB::Port") and cnf["DB::Port"] != "-1":
connstr += ":%s" % cnf["DB::Port"]
connstr += "/%s" % cnf["DB::Name"]
else:
# Unix Socket
connstr = "postgresql:///%s" % cnf["DB::Name"]
connstr += ":%s" % cnf["DB::Port"]
connstr += "/%s" % cnf["DB::Name"]
else:
# Unix Socket
connstr = "postgresql:///%s" % cnf["DB::Name"]
- if cnf["DB::Port"] and cnf["DB::Port"] != "-1":
+ if cnf.has_key("DB::Port") and cnf["DB::Port"] != "-1":
connstr += "?port=%s" % cnf["DB::Port"]
engine_args = { 'echo': self.debug }
connstr += "?port=%s" % cnf["DB::Port"]
engine_args = { 'echo': self.debug }