更新时间:2022-05-18 23:10:02
Python 不能直接使用 sqlite3
二进制文件.它总是使用一个链接到 sqlite3
共享库的模块.这意味着您必须按照如何在 virtualenv 中升级 python 2.7.3 中的 sqlite3?" 在您的 virtualenv 中创建 pysqlite
模块的一个版本.
Python can't use the sqlite3
binary directly. It always uses a module which is linked against the sqlite3
shared library. That means you have to follow the instructions in "How to upgrade sqlite3 in python 2.7.3 inside a virtualenv?" to create a version of the pysqlite
module in your virtualenv.
然后您可以使用此导入
from pysqlite2 import dbapi2 as sqlite
用新的模块遮蔽系统默认的 sqlite
模块.
to shadow the system's default sqlite
module with the new one.
另一个选择是获取 Python 的源代码,编译所有内容并将文件 sqlite.so
复制到您的 virtualenv 中.这种方法的缺点是它很脆弱,很难被其他人重复.
Another option would be to get Python's source code, compile everything and copy the file sqlite.so
into your virtualenv. The drawback of this approach is that it's brittle and hard to repeat by other people.