在Debian上升级Python的sqlite3


问题内容

我在Debian的linux2上使用Python 2.7.6(默认值,2014年3月22日,22:59:56)[GCC
4.8.2],并且我通常使用模块sqlite3没有任何问题。

编译了一个Sqlite扩展
spellfix,加载时出现此错误:

sqlite3.OperationalError:./spellfix.so:未定义符号:sqlite3_malloc64

我认为可能是因为sqlite3模块太旧:

import sqlite3
print sqlite3.version          # 2.6.0
print sqlite3.sqlite_version   # 3.8.2

(在另一台sqlite3.sqlite_version3.8.7.x的计算机上,扩展名加载正常)。

我试过了:

pip install --upgrade pysqlite

但仍然相同:sqlite3.sqlite_version保持3.8.2。

如何升级Python sqlite3模块(标准库中内置)?


问题答案:

您以为是版本sqlite3引起问题的想法是正确的。sqlite_malloc643.8.7版中引入。

建议不要sqlite3编译spellfix.c3.8.2版本中包含的版本,而不是尝试升级可能最终破坏Python安装的Python模块。

您可以在此处找到源:https
:
//www.sqlite.org/src/tarball/27392118/SQLite-27392118.tar.gz

从那里,您可以使用以下方法建立合并:

sh configure
make sqlite3.c

您将在文件夹中有sqlite3.hand 。然后使用以下命令编译扩展:sqlite3ext.h``tsrc``spellfix.c

gcc -g -fPIC -shared spellfix.c -I ../../tsrc -o spellfix.dll

而且您应该获得spellfix.dll与您的sqlite3版本兼容的兼容性。