Escape Python to `json[]` for `COPY FROM` PostgreSQL insertion? - Mailing list psycopg

From Samuel Marks
Subject Escape Python to `json[]` for `COPY FROM` PostgreSQL insertion?
Date
Msg-id CAMfPbcbOoC0k2CoSDo1jR-nh98N5qs_aU1T9hEXYpMfpQb-bZA@mail.gmail.com
Whole thread Raw
Responses Re: Escape Python to `json[]` for `COPY FROM` PostgreSQL insertion?  (Adrian Klaver <adrian.klaver@aklaver.com>)
Re: Escape Python to `json[]` for `COPY FROM` PostgreSQL insertion?  (Aryeh Leib Taurog <aryehleib@aryehleib.com>)
Re: Escape Python to `json[]` for `COPY FROM` PostgreSQL insertion?  (Daniele Varrazzo <daniele.varrazzo@gmail.com>)
List psycopg
How do I insert into a table with a `json[]` column using the `COPY FROM` syntax?


Error:
psycopg2.errors.InvalidTextRepresentation: malformed array literal: "{"jj":null,"text":"bop"}"

Or when I try to json.dump the dict twice I get:
psycopg2.errors.InvalidTextRepresentation: malformed array literal: ""{"jj":null,"text":"bop"}"" DETAIL:  Array value must start with "{" or dimension information. CONTEXT:  COPY my_table, line 1, column json_arr_col: ""{"jj":null,"text":"bop"}""

I'm using your `copy_expert` function. PS: Also asked on https://stackoverflow.com/q/75511919

Am I meant to represent the lists with braces rather than square brackets? - Or should I be using some internal psycopg function as opposed to my hacked together `parse_col` function?

Thanks,

Samuel Marks

psycopg by date:

Previous
From: Daniele Varrazzo
Date:
Subject: Re: bug in handling Postgres bytea type?
Next
From: Adrian Klaver
Date:
Subject: Re: Escape Python to `json[]` for `COPY FROM` PostgreSQL insertion?