Creating JSON type Column in SQLite with sqlalchemy(使用 sqlalchemy 在 SQLite 中创建 JSON 类型的列)
问题描述
是否可以使用 sqlalchemy 在 SQLite 中创建 JSON 类型的列?我试过了
Is it possible to create JSON type Column in SQLite with sqlalchemy? I've tried
import sqlalchemy.types as types
...
myColumn = Column(types.JSON())
和
from sqlalchemy import JSON
...
mycolumn = Column(JSON)
两者都收到错误消息:
编译器无法渲染
想知道在 sqlalchemy 中是否有任何解决方案,或者我应该改为改为 SQL.提前致谢.
Wondering if there is any solution in sqlalchemy or I should just change into SQL instead. Thanks in advance.
[更新] SQLite 3.16.0 版
[Updates] SQLite version 3.16.0
推荐答案
JSON 直到 3.9 版才添加到 SQLite.您需要升级您的 SQLite 或将您的 json 转换为字符串并按原样保存,同时在将其拉出时将其转换回 json 对象.
JSON was not added to SQLite until version 3.9. You'll either need to upgrade your SQLite or convert your json to a string and save it as such, while converting it back to a json object when you pull it out.
这篇关于使用 sqlalchemy 在 SQLite 中创建 JSON 类型的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 sqlalchemy 在 SQLite 中创建 JSON 类型的列
基础教程推荐
- MySQL 中的类型:BigInt(20) 与 Int(20) 2021-01-01
- 如何根据该 XML 中的值更新 SQL 中的 XML 2021-01-01
- 在多列上分布任意行 2021-01-01
- mysql选择动态行值作为列名,另一列作为值 2021-01-01
- 什么是 orradiag_<user>文件夹? 2022-01-01
- 表 './mysql/proc' 被标记为崩溃,应该修复 2022-01-01
- 在 MySQL 中:如何将表名作为存储过程和/或函数参数传递? 2021-01-01
- 二进制文件到 SQL 数据库 Apache Camel 2021-01-01
- 如何在 SQL 中将 Float 转换为 Varchar 2021-01-01
- oracle区分大小写的原因? 2021-01-01
