python - 将图像插入 PostgresSQL
问题描述
我试图插入一个 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);
推荐阅读
- c++ - 存储最小数量的静态变量
- laravel - Vue-laravel 中的动态 CSS 有问题
- javascript - Firebase orderByChild 在我的数据库中不起作用
- arrays - 图像模糊问题
- linux - 文件存在于 shell 脚本中
- windows - PS:模拟CCleaner“卸载”工具列出PC上安装的程序
- python - 如何初始化整个 Python 模块并导入所有类,而无需为每次调用引用模块名称?
- oracle - 无法确定“oracle”的方言
- django - 如何运行 makemigrations
--empty 与 Django 和 Docker? - machine-learning - 交叉验证:训练/测试集拆分有必要吗?