Minor change for postgres connection--not tested w/remote db.

This commit is contained in:
Ray 2009-06-02 10:59:54 -04:00
parent 9826138744
commit 5013a07fc0

View File

@ -66,17 +66,16 @@ class fpdb_db:
psycopg2.extensions.register_type(psycopg2.extensions.UNICODE) psycopg2.extensions.register_type(psycopg2.extensions.UNICODE)
# If DB connection is made over TCP, then the variables # If DB connection is made over TCP, then the variables
# host, user and password are required # host, user and password are required
if self.host and self.user and self.password: # For local domain-socket connections, only DB name is
# needed, and everything else is in fact undefined and/or
# flat out wrong
if self.host == "localhost" or self.host == "127.0.0.1":
self.db = psycopg2.connect(database = database)
else:
self.db = psycopg2.connect(host = host, self.db = psycopg2.connect(host = host,
user = user, user = user,
password = password, password = password,
database = database) database = database)
# For local domain-socket connections, only DB name is
# needed, and everything else is in fact undefined and/or
# flat out wrong
else:
self.db = psycopg2.connect(database = database)
# self.db.set_client_encoding('UNICODE')
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()