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 类型的列


基础教程推荐
- 在 VB.NET 中更新 SQL Server DateTime 列 2021-01-01
- 将数据从 MS SQL 迁移到 PostgreSQL? 2022-01-01
- ERROR 2006 (HY000): MySQL 服务器已经消失 2021-01-01
- SQL Server 2016更改对象所有者 2022-01-01
- SQL Server 中单行 MERGE/upsert 的语法 2021-01-01
- 使用pyodbc“不安全"的Python多处理和数据库访问? 2022-01-01
- Sql Server 字符串到日期的转换 2021-01-01
- 无法在 ubuntu 中启动 mysql 服务器 2021-01-01
- 如何在 SQL Server 的嵌套过程中处理事务? 2021-01-01
- SQL Server:只有 GROUP BY 中的最后一个条目 2021-01-01