且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 Python 2.6 中升级 sqlite3 包?

更新时间:2022-10-17 22:36:16

sqlite3 不是内置模块;它是一个扩展模块(二进制文件是 C:Python26DLLs_sqlite3.pyd(在我的机器上)).pyd 是具有不同文件扩展名且只有 1 个入口点的 DLL.还有一个 sqlite3.dll,其中包含 SQLite 代码.python.exe 不与其中任何一个链接,因此重建 python.exe 没有意义.

下一个想法是访问 pysqlite2 下载站点,并获取适用于 Python 2.6 的最新 Windows 安装程序.不幸的是,没有关于它包含哪个版本的 SQLite 的文档;一个人需要安装它然后乱搞:

>>>导入 sqlite3 作为标准>>>从 pysqlite2 导入 dbapi2 作为最新版本>>>对于 m in(标准,最新):... 打印 m.sqlite_version...3.5.93.6.2>>>

因此,它仅包含 SQLite 3.6.2 版,它没有您想要的真正的外键支持.

我建议您查看邮件列表以查看是否您的问题在那里得到了回答,如果没有,请询​​问 Python 2.6 安装程序是否有可能包含更高版本的 SQLite(例如 Python 2.7 中包含的那个).

I was using Python 2.6.5 to build my application, which came with sqlite3 3.5.9. Apparently though, as I found out in another question of mine, foreign key support wasn't introduced in sqlite3 until version 3.6.19. However, Python 2.7 comes with sqlite3 3.6.21, so this work -- I decided I wanted to use foreign keys in my application, so I tried upgrading to python 2.7.

I'm using twisted, and I couldn't for the life of me get it to build. Twisted relies on zope.interface and I can't find zope.interface for python 2.7 -- I thought it might just "work" anyway, but I'd have to just copy all the files over myself, and get everything working myself, rather than just using the self-installing packages.

So I thought it might be wiser to just re-build python 2.6 and link it against a new version of sqlite3. But I don't know how--

How would I do this?

I have Visual Studio 2008 installed as a compiler, I read that that is the only one that is really supported for Windows, and I am running a 64 bit operating system

sqlite3 is not a built-in module; it's an extension module (the binary is C:Python26DLLs_sqlite3.pyd (on my machine)). A pyd is a DLL with a different filename extension and only 1 entry point. There's also a sqlite3.dll, which contains the SQLite code. python.exe is not linked against either of those, and thus rebuilding python.exe has no point.

The next idea is to go to the pysqlite2 download site, and get the latest Windows installer for Python 2.6. Unfortunately there's no docs about which version of SQLite it contains; one needs to install it and then muck about:

>>> import sqlite3 as standard
>>> from pysqlite2 import dbapi2 as latest
>>> for m in (standard, latest):
...    print m.sqlite_version
...
3.5.9
3.6.2
>>>

So, it contains only SQLite version 3.6.2, which doesn't have the real foreign key support that you want.

I suggest that you check the mailing list to see if your question is answered there, and if not ask about the possibility of a Python 2.6 installer containing a later SQLite (e.g. the one included with Python 2.7).