问题
command = (
CREATE TYPE belongings AS (
item TEXT,
quantity INTEGER
)
CREATE TYPE student AS (
name TEXT,
id INTEGER,
bag belongings[]
)
CREATE TABLE studentclass(
date DATE NOT NULL,
time TIMESTAMPTZ NOT NULL,
PRIMARY KEY (date, time),
class student
)
)
Can i ask how to do insert for this in postgres psycog2? thank you.
When i put the insert as insert_sql = "INSERT INTO studentclass (date, time, class) VALUES (%s,%s,%s)"
error output is DETAIL: Cannot cast type text[] to belongings[] in column
I don't think i just cast it with "::belongings[]" in the INSERT statement as it is a nested.
My earlier asked question for a simpler table.
Unable to insert nested record in postgres
来源:https://stackoverflow.com/questions/64922416/insertion-of-nested-array-of-custom-in-table-for-postgres