fix quit option and postgres/windows connecting after last merges
This commit is contained in:
parent
8a55b2ebd9
commit
9d87e35082
|
@ -409,7 +409,7 @@ class fpdb:
|
||||||
return self.fdb_lock.get_global_lock()
|
return self.fdb_lock.get_global_lock()
|
||||||
#end def obtain_global_lock
|
#end def obtain_global_lock
|
||||||
|
|
||||||
def quit(self, widget, data):
|
def quit(self, widget, data=None):
|
||||||
print "Quitting normally"
|
print "Quitting normally"
|
||||||
#check if current settings differ from profile, if so offer to save or abort
|
#check if current settings differ from profile, if so offer to save or abort
|
||||||
self.db.disconnect()
|
self.db.disconnect()
|
||||||
|
|
|
@ -179,13 +179,28 @@ class fpdb_db:
|
||||||
# For local domain-socket connections, only DB name is
|
# For local domain-socket connections, only DB name is
|
||||||
# needed, and everything else is in fact undefined and/or
|
# needed, and everything else is in fact undefined and/or
|
||||||
# flat out wrong
|
# flat out wrong
|
||||||
|
# sqlcoder: This database only connect failed in my windows setup??
|
||||||
|
# Modifed it to try the 4 parameter style if the first connect fails - does this work everywhere?
|
||||||
|
connected = False
|
||||||
if self.host == "localhost" or self.host == "127.0.0.1":
|
if self.host == "localhost" or self.host == "127.0.0.1":
|
||||||
self.db = psycopg2.connect(database = database)
|
try:
|
||||||
else:
|
self.db = psycopg2.connect(database = database)
|
||||||
self.db = psycopg2.connect(host = host,
|
connected = True
|
||||||
user = user,
|
except:
|
||||||
password = password,
|
pass
|
||||||
database = database)
|
#msg = "PostgreSQL direct connection to database (%s) failed, trying with user ..." % (database,)
|
||||||
|
#print msg
|
||||||
|
#raise fpdb_simple.FpdbError(msg)
|
||||||
|
if not connected:
|
||||||
|
try:
|
||||||
|
self.db = psycopg2.connect(host = host,
|
||||||
|
user = user,
|
||||||
|
password = password,
|
||||||
|
database = database)
|
||||||
|
except:
|
||||||
|
msg = "PostgreSQL connection to database (%s) user (%s) failed." % (database, user)
|
||||||
|
print msg
|
||||||
|
raise fpdb_simple.FpdbError(msg)
|
||||||
else:
|
else:
|
||||||
raise fpdb_simple.FpdbError("unrecognised database backend:"+backend)
|
raise fpdb_simple.FpdbError("unrecognised database backend:"+backend)
|
||||||
self.cursor=self.db.cursor()
|
self.cursor=self.db.cursor()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user