Example:
Traceback (most recent call last):
File "/usr/sbin/prepare_postgres", line 46, in <module>
pg_exec_postgres("ALTER USER postgres WITH PASSWORD %s", [POSTGRES_PASSWORD])
File "/opt/util.py", line 101, in pg_exec_postgres
return pg_conn_postgres().execute(*args, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/psycopg/connection.py", line 722, in execute
raise ex.with_traceback(None)
psycopg.errors.SyntaxError: syntax error at or near "$1"
LINE 1: ALTER USER postgres WITH PASSWORD $1
^
PostgreSQL server log:
2022-01-05 17:35:25.831 CET [58] ERROR: syntax error at or near "$1" at character 35
2022-01-05 17:35:25.831 CET [58] STATEMENT: ALTER USER postgres WITH PASSWORD $1
Passwords can also contain special characters. If I can't use parameters to do this, then how should I quote them in a safe way?
Thank you,
Laszlo