使用sqlalchemy在SQLite中创建JSON类型列 [英] Creating JSON type Column in SQLite with sqlalchemy
本文介绍了使用sqlalchemy在SQLite中创建JSON类型列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以使用sqlalchemy在SQLite中创建JSON类型的Column? 我已经尝试过
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)
均获得错误消息:
编译器无法呈现
Compiler can't render element of type
想知道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类型列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文