postgresql - 在 postgres 的表中插入嵌套的自定义数组
问题描述
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
)
)
我可以问如何在 postgres psycog2 中为此插入吗?谢谢你。
当我将插入作为 insert_sql = "INSERT INTO studentclass (date, time, class) VALUES (%s,%s,%s)"
错误输出为详细信息:无法将类型文本 [] 转换为列中的财物 []
我不认为我只是在 INSERT 语句中使用 "::belongings[]" 进行转换,因为它是嵌套的。
我之前提出的更简单表格的问题。
解决方案
推荐阅读
- c# - 如何使用同一个控制台应用程序处理多个用户?
- c# - 有没有办法使用 DataTemplate 来定义在代码中创建的 Border 对象的结构?
- cmake - 如何在安装语句中使用 cmake 文件(GET_RUNTIME_DEPENDENCIES?
- amazon-web-services - AWS ec2 实例未运行更新
- core-audio - 禁用 AudioUnit AGC 失败
- python - python jupyter 使用 ls 命令列出所有 s3 文件
- java - Flink StreamingFileSink 的问题
& Azure Datalake Gen 2 - python - 寻找一种干净的方法来将额外的零通道添加到具有未知批量大小的 NxNxC 张量?
- python - 热图:从数据框索引中取轴
- sqlite - 使用 Sqlite JavaFx 填充 tableview 疑难解答