关于django.db.utils.NotSupportedError: deterministic=True requires SQLite 3.8.3错误的处理办法

标签:,
来源: 老季博客
日期: 2021-12-4
作者: 腾讯云/服务器VPS推荐评测/Vultr
阅读数: 49

最近,很多朋友都把自己的操作系统、Python、Django都升级到最新版本了,使用默认SQLite数据,运行时会报出类似django.db.utils.NotSupportedError: deterministic=True requires SQLite 3.8.3的错误提示。这主要是操作系统默认SQLite数据库版本太低造成的。这里给大家提供三种解决办法,希望能帮到大家。

第一种:

升级系统里的SQLite版本。方法:https://www.django.cn/forum/forum-487.html

注意,如需要最新版本的话,请从官网下载最新的软件包。 下载址:https://www.sqlite.org/download.html

第二种:找到报错文件,如/usr/local/python3/lib/python3.8/site-packages/django/db/backends/sqlite3/base.py 打开它,找到

def check_sqlite_version():
    if Database.sqlite_version_info < (3, 9, 0):

把里面小括号里的 SQLite版本(3,9,0)修改成你当前系统里版本就好。

第三种:

使用第三方包运行SQLite。把sqlite3 更换为pysqlite3 和 pysqlite3-binary方法:1、安装pysqlite3和pysqlite3-binary

pip install pysqlite3
pip install pysqlite3-binary

2、打开文件/usr/local/python3/lib/python3.8/site-packages/django/db/backends/sqlite3/base.py,找到 from sqlite3 import dbapi2 as Database 注释它,添加代码

#from sqlite3 import dbapi2 as Database  #注释它
from pysqlite3 import dbapi2 as Database #新加这段代码

三种,总有一种适合你。

链接到文章: https://jiloc.com/47542.html

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注