Search code examples
pythonauthenticationwrds-compusat

Python - .pgpass not remembering login information


I frequently use Wharton Research Data Services (WRDS) through Python on my mac. Here is the code I use to log in:

    conn = wrds.Connection()

And here is the message I get after entering my username and password:

    Enter your WRDS username [user]:username
    Enter your password:········
    WRDS recommends setting up a .pgpass file.
    Create .pgpass file now [y/n]?: y
    Created .pgpass file successfully.
    Loading library list...
    Done

As you can see, I always reply "y" to the "Create .pgpass file" line and it always says that it was successfully created. I was under the impression that this meant my Python would remember my username and password. However, I still get prompted to fill it in each time that I log in. It's not the biggest issue, but it can get pretty annoying having to enter my information each time.

Please let me know if there is a way I could fix this issue.


Solution

    1. Check that the file ~/.pgpass exists. It should contain something that looks like this:

    wrds-pgdata.wharton.upenn.edu:9737:wrds:YOUR_WRDS_USER:YOUR_WRDS_PWD

    1. Make sure it has the right permissions (details here)

    chmod 0600 ~/.pgpass