Skip to main content

Library for getting passwords from PostgreSQL password files

Project description

pgpasslib is a library for retrieving passwords from a PostgreSQL password file, either from a location specified in the PGPASSFILE environment variable or in the .pgpass file in the current user’s home directory.

Version Downloads Status Coverage Code Climate


pgpasslib may be installed via the Python package index with the tool of your choice. I prefer pip:

pip install pgpasslib


There are no requirements outside of the Python standard library.


The following example will attempt to get the password for PostgreSQL running on localhost:5432 to the postgres database as the postgres user.

import pgpasslib

password = pgpasslib.getpass('localhost', 5432, 'postgres', 'postgres')
if not password:
    raise ValueError('Did not find a password in the .pgpass file')

Version History

Available at

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
pgpasslib-1.1.0-py2.py3-none-any.whl (7.8 kB) Copy SHA256 hash SHA256 Wheel py2.py3
pgpasslib-1.1.0.tar.gz (5.2 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page