peewee.OperationalError: no such function: json
peewee.OperationalError: no such function: json
Python版本:3.8.3
Peewee 版本:3.13.3
我想创建一个包含 JSONField 的对象,
db = SqliteExtDatabase('../db.sqlite', pragmas=(('journal_mode', 'wal'), ('foreign_keys', 1)))
class Msg(BaseModel):
id = AutoField()
detail = JSONField()
def insert_msg(detail: dict):
msg = Msg.create(detail=detail)
msg.save()
但是当我调用方法 insert_msg({"name":"abc"}) 时,出现错误
peewee.OperationalError: no such function: json
您需要安装 sqlite json1 扩展。以下是一些可能有帮助的链接:
- http://charlesleifer.com/blog/compiling-sqlite-for-use-with-python-applications/
- https://sqlite.org/json1.html
- https://github.com/coleifer/pysqlite3(pip install pysqlite3-binary for pre-compiled/statically-linked pysqlite with json ext)
Python版本:3.8.3
Peewee 版本:3.13.3
我想创建一个包含 JSONField 的对象,
db = SqliteExtDatabase('../db.sqlite', pragmas=(('journal_mode', 'wal'), ('foreign_keys', 1)))
class Msg(BaseModel):
id = AutoField()
detail = JSONField()
def insert_msg(detail: dict):
msg = Msg.create(detail=detail)
msg.save()
但是当我调用方法 insert_msg({"name":"abc"}) 时,出现错误
peewee.OperationalError: no such function: json
您需要安装 sqlite json1 扩展。以下是一些可能有帮助的链接:
- http://charlesleifer.com/blog/compiling-sqlite-for-use-with-python-applications/
- https://sqlite.org/json1.html
- https://github.com/coleifer/pysqlite3(pip install pysqlite3-binary for pre-compiled/statically-linked pysqlite with json ext)