From 5013a07fc0022bbd0d36c506879dea8873e8b82f Mon Sep 17 00:00:00 2001 From: Ray Date: Tue, 2 Jun 2009 10:59:54 -0400 Subject: [PATCH] Minor change for postgres connection--not tested w/remote db. --- pyfpdb/fpdb_db.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/pyfpdb/fpdb_db.py b/pyfpdb/fpdb_db.py index e8ff8109..a0939b39 100644 --- a/pyfpdb/fpdb_db.py +++ b/pyfpdb/fpdb_db.py @@ -66,17 +66,16 @@ class fpdb_db: psycopg2.extensions.register_type(psycopg2.extensions.UNICODE) # If DB connection is made over TCP, then the variables # 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, user = user, password = password, 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: raise fpdb_simple.FpdbError("unrecognised database backend:"+backend) self.cursor=self.db.cursor()