Python sqlite3:运行不同的sqlite3版本 [英] Python sqlite3: run different sqlite3 version

查看:49
本文介绍了Python sqlite3:运行不同的sqlite3版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行一个使用 sqlite 作为数据库之一的 Django 项目.我想在运行项目时运行最新的 SQLite 版本.我的意思是最新的 sqlite 二进制文件,而不是 sqlite python 库.

I'm running a Django project using sqlite as one of the databases. I would like to run the most recent SQLite version when running the project. By that I mean the most recent sqlite binary, not the sqlite python library.

我有一个不是系统默认值的本地 sqlite3 二进制文件,我无法更改默认的 sqlite3 版本.

I have a local sqlite3 binary that is not the system default and I can't change the default sqlite3 version.

我没有使用 Django 的 ORM,而是将其替换为独立的 SQLAlchemy 版本.

I'm not using Django's ORM but have replaced it with a standalone SQLAlchemy version.

我找到了一个相关链接,但这与运行最新的 python sqlite 库版本有关.

I've found one related link but that had to do with running the most recent python sqlite library version.

如何升级 sqlite3python 2.7.3 在 vi​​rtualenv 中?

推荐答案

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.

这篇关于Python sqlite3:运行不同的sqlite3版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆