psycopg3 - parameters cannot be used for DDL commands?

Поиск
Список
Период
Сортировка
От Les
Тема psycopg3 - parameters cannot be used for DDL commands?
Дата
Msg-id CAKXe9UDix+STcO8akzNNhjS4tEZd7xs203XNn72G35ELm81=WQ@mail.gmail.com
обсуждение исходный текст
Ответы Re: psycopg3 - parameters cannot be used for DDL commands?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-interfaces
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


В списке pgsql-interfaces по дате отправления:

Предыдущее
От: Dave Cramer
Дата:
Сообщение: Re: PostgreSQL XA resource manager for C/C++ apps
Следующее
От: Tom Lane
Дата:
Сообщение: Re: psycopg3 - parameters cannot be used for DDL commands?