jwp/py-postgresql — Issue #57: Else statement needed..and USERNAME dependency.
Author: zig007
Created: 2011-12-07 21:30:26+00:00
State: open

Hi!

There is a use case not being handled here, causing it to fail on my WinXP machine(variable isn't initialised).
It is at line 142 at clientparameters.py:
-----------------------------------------------------------
if sys.platform == 'win32':
appdata = environ.get('APPDATA')
if appdata:
pgdata = os.path.join(appdata, pg_appdata_directory)
pgpassfile = os.path.join(pgdata, pg_appdata_passfile)
else:
-----------------------------------------------------------

Adding an else statement on appdata like at least makes the error go away and the test succeed on my install:
-----------------------------------------------------------
if appdata:
pgdata = os.path.join(appdata, pg_appdata_directory)
pgpassfile = os.path.join(pgdata, pg_appdata_passfile)
+	else:
+	pgpassfile = ''

Also, the USERNAME environment variable seem to be necessary on windows but not on linux.
I don't see why "user" doesn't seem to be passed from postgresql.driver.dbapi20.connect?
I makes it far less portable.

Otherwise, great work!