My goal is to use getpass to hide the entry of my password when I connect to a postgresql database via python3. I use python3 on jyputer notebook.
This work well :
connect = psycopg2.connect("dbname='db_toto' user='dad' host='xx.xx.xxx.x' port='5432' password='123456'")
cur = connect.cursor()
But when I try to enter the password with a separate variable, it does not work anymore :
pw = getpass.getpass()
####Python ask me to tape password and i tape the same '123456'
To verify :
'123456'
connect=psycopg2.connect("dbname='db_toto' user='dad' host='xx.xx.xxx.x' port='5432' password=pw")
cur=connect.cursor()
" OperationalError: FATAL: password authentication failed for user
FATAL: password authentication failed for user "
Thanks you for your help