Re: Escape Python to `json[]` for `COPY FROM` PostgreSQL insertion?

Поиск
Список
Период
Сортировка
От Daniele Varrazzo
Тема Re: Escape Python to `json[]` for `COPY FROM` PostgreSQL insertion?
Дата
Msg-id CA+mi_8YZt4QjUY5YMTUVZGByRZ88f=X=TEoLuJG6ZQy3SiuW8w@mail.gmail.com
обсуждение исходный текст
Ответ на Escape Python to `json[]` for `COPY FROM` PostgreSQL insertion?  (Samuel Marks <samuelmarks@gmail.com>)
Список psycopg
On Tue, 21 Feb 2023 at 05:34, Samuel Marks <samuelmarks@gmail.com> wrote:
>
> How do I insert into a table with a `json[]` column using the `COPY FROM` syntax?

you can just use psycopg 3 and pass it the records as tuples with the
objects you want to copy. The values of your json[] fields can be a
list of `Json` wrappers.

https://www.psycopg.org/psycopg3/docs/basic/copy.html#writing-data-row-by-row
https://www.psycopg.org/psycopg3/docs/basic/adapt.html#json-adaptation

If you want to know the escaping rules, they are in the Postgres documentation:

https://www.postgresql.org/docs/current/arrays.html#ARRAYS-INPUT

-- Daniele



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

Предыдущее
От: Aryeh Leib Taurog
Дата:
Сообщение: Re: Escape Python to `json[]` for `COPY FROM` PostgreSQL insertion?
Следующее
От: "Michael P. McDonnell"
Дата:
Сообщение: Consecutive Inserts Freeze Execution of Psycopg3