I'm working on a small code, which have to:
I am willing to use password as a plain text.
For the moment my code is:
import pysftp
command = "... some SQL command"
sftp= pysftp.Connection('server_name', username='username', password='password')
sftp.execute("export PGPASSWORD='password_to_psql'")
sftp.execute("psql -h 127.0.0.1 -d {} -U {} -W -c "{}"").format(database_name, user_name, command)
sftp.close()
I thought it was good idea, but when i type proper command in terminal, shell prompts for password (but is not required, when i 'enter', everything is executed.
Does anyone knows how can i 'disable' prompts, which are not required?
psql
has a --no-password
option, which can also be specified as -w
.
It looks like you might have misspelled -w
as -W
, which has the opposite effect.