Empty db_name means login with local account (identd) for postgres

This commit is contained in:
alba 2002-08-07 20:33:01 +00:00
parent 74b9c2d1a7
commit 72bac70ad9
1 changed files with 7 additions and 1 deletions

View File

@ -31,6 +31,8 @@ AUTOCOMMIT = 1
# Modules ##################################################################
import os
import pwd
import pyPgSQL
from Config import config
from Log import log
@ -119,7 +121,11 @@ class PgSQLDatabase(Database):
def __init__(self, db_name, db_host):
from pyPgSQL import PgSQL
self.connection = PgSQL.connect(database=db_name, host=db_host)
if len(db_host) == 0:
db_user = pwd.getpwuid(os.geteuid())[0]
self.connection = PgSQL.connect(database=db_name, user=db_user)
else:
self.connection = PgSQL.connect(database=db_name, host=db_host)
self.connection.autocommit = AUTOCOMMIT
class MySQLDatabase(Database):