Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
685 views
in Technique[技术] by (71.8m points)

sqlite - Upgrade Python's sqlite3 on Debian

I'm using Python 2.7.6 (default, Mar 22 2014, 22:59:56) [GCC 4.8.2] on linux2 on my Debian, and I'm usually using module sqlite3 without any problem.

I compiled a Sqlite extension spellfix, I get this error when loading it:

sqlite3.OperationalError: ./spellfix.so: undefined symbol: sqlite3_malloc64

I think it might be because the sqlite3 module is too old:

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

(On another machine where sqlite3.sqlite_version is 3.8.7.x the extension loads fine).

I tried:

pip install --upgrade pysqlite

but it's still the same: sqlite3.sqlite_version stays 3.8.2.

How to upgrade the Python sqlite3 module (which is built-in in the standard library)?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You are right in thinking that the version of sqlite3 causes the problem. sqlite_malloc64 was introduced with release 3.8.7.

Instead of trying to upgrade the Python sqlite3 module which may end up breaking your Python installation, I would suggest compiling the version of spellfix.c included with version 3.8.2.

You can find the source here: https://www.sqlite.org/src/tarball/27392118/SQLite-27392118.tar.gz

From there you can build the amalgamation with:

sh configure
make sqlite3.c

You will have sqlite3.h and sqlite3ext.h in the tsrc folder. Then compile the spellfix.c extension with:

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

And you should get a compatible spellfix.dll that runs with your version of sqlite3.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...