all!
We currently use MTPuTTY to SSH into a Red Hat Linux server to run Python programs on a compute cluster. I was wanting to implement read-only access to a PostgreSQL database into these programs using the current credentials used for SSH. I know you can't access the password via Linux and it would be (very) bad practice to store the passwords in plaintext (does this still count for folders only accessible by the users?, ie dedicated network storage folders? I suppose that would depend on if admins have access to those folders as well).
I was hoping there would be some way to use the current SSH session credentials to authenticate with the database and fetch records into the Python program, but can't seem to find a way to do that. Is there a way? Is there an alternative?
Other options I've thought of:

Create server to take requests using my credentials, fetch records,
return records to program.
Run service/scheduled task to fetch values every [x] minutes, store
in a file accessible only by my group (though not sure how to do
this without storing my password in an accessible manner).

Just really not seeing a safe way to automate this access without exposing passwords... Any help is much appreciated! Thank you!
You should be able to make both Linux and PostgreSQL use PAM.
But why not just keep it simple and use peer authentication?  The fact that you logged on to the linux account shows you knew the password to do that log on.  Isn't that enough?
Using current Linux SSH Credentials to authenticate for database access in python program