我试图插入到 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/