gpt4 book ai didi

python - 将图像插入 PostgresQL

转载 作者:行者123 更新时间:2023-12-03 01:00:58 25 4
gpt4 key购买 nike

我试图插入到 postgres 数据库中。这是查询

INSERT INTO public.tblcast(
castname, castimage)
VALUES ('Henry Cavill',bytea('E:\Cast\henry.jpg'));

但是显示错误

ERROR:  invalid input syntax for type bytea
LINE 3: VALUES ('Henry Cavill',bytea('E:\Cast\henry.jpg'));
^
SQL state: 22P02
Character: 81ERROR: invalid input syntax for type bytea

列castimage的数据类型为bytea。

最佳答案

使用pg_read_file

INSERT INTO public.tblcast(
castname, castimage)
VALUES ('Henry Cavill',pg_read_file('E:\Cast\henry.jpg')::bytea);

关于python - 将图像插入 PostgresQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59198586/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com