def set_pgpass(database):
    pgpass_file = os.path.expanduser('~')
    pgpass_file = os.path.join(pgpass_file, '.pgpass')
    
    db_host = database['HOST']
    db_port = database['PORT']
    #db_name = database['NAME']
    # Wildcarded for dropdb.
    db_name = '*'
    db_user = database['USER']
    db_pass = database['PASSWORD']
    
    if db_host is '':
        db_host = '*'
    if db_port is '':
        db_port = '*'
    
    fd = open(pgpass_file, 'wb')
    # host:port:database:username:password
    fd.write('%s:%s:%s:%s:%s' % (db_host, db_port, db_name, db_user, db_pass))
    fd.close()
    
    perms = stat.S_IRUSR | stat.S_IWUSR
    os.chmod(pgpass_file, perms)
Sets the ~/.pgpass file up so that psql and pg_dump doesn't ask 
dataset/ETHPy150Open duointeractive/django-fabtastic/fabtastic/db/postgres.py/set_pgpass