public inbox for [email protected]
help / color / mirror / Atom feedFrom: Les <[email protected]>
To: [email protected]
Subject: psycopg3 - parameters cannot be used for DDL commands?
Date: Wed, 5 Jan 2022 17:42:31 +0100
Message-ID: <CAKXe9UDix+STcO8akzNNhjS4tEZd7xs203XNn72G35ELm81=WQ@mail.gmail.com> (raw)
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
view thread (6+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: psycopg3 - parameters cannot be used for DDL commands?
In-Reply-To: <CAKXe9UDix+STcO8akzNNhjS4tEZd7xs203XNn72G35ELm81=WQ@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox