问题
I want to use sqlite3 with Python 3.1.3 and I need to set enable_load_extension to true. To do this I believe I need sqlite version 3.x. From reading posts here it looks like a suitable version of sqlite ought to be bundled with python version 2.6 and up. However, when I do:
import sqlite3
sqlite3.version_info
The result returned is: '2.4.1'
I get the same answer on a different machine running Python 2.6.
The pysqlite site has no binaries for Python 3.x. My copy of Python came from the official Python site.
So: 1) What version of sqlite should I have with 3.1? 2) If I ought to have a more up to date version where has it gone - do I need to set an environment variable? 2) If I need to u
回答1:
Don't confuse the version of SQLite with the version of pysqlite, the Python binding for the SQLite API. The version
and version_info
attributes you used refer to the latter.
Ever wondered why the module is named sqlite3
? It only supports version 3.x!
To check the SQLite version, use sqlite_version
instead:
import sqlite3
print sqlite3.sqlite_version
On my Python 2.6 installation, this prints 3.5.9
. For Python 3.2, I get 3.7.4
.
You can also use SQL to get the version:
>>> import sqlite3
>>> connection = sqlite3.connect(':memory:')
>>> cursor = connection.cursor()
>>> cursor.execute('SELECT sqlite_version()').fetchone()
('3.7.4',)
回答2:
You need sqlite3.sqlite_version_info
... this is 3.5.9 for Python 2.6 and 3.1, 3.6.21 for Python 2.7, and 3.7.4 for Python 3.2. What you have got is the version of pysqlite.
Have you tried to "set enable_load_extension to true"?
You may wish to read some of this long saga ...
来源:https://stackoverflow.com/questions/6357074/sqlite-version-for-python-3-x