Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I upgrade the sqlite3 package in Python 2.6?

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

like image 666
Carson Myers Avatar asked Jul 26 '10 07:07

Carson Myers


People also ask

What is SQLite3 version in Python?

sqlite3.version gets you the version of the Python 'sqlite3' database adapter module. The version we care about - the actual version of SQLite - is sqlite3.sqlite_version. That's not confusing at all!

What is update in SQLite?

UPDATE Operation on any database implies modifying the values of one or more records of a table, which are already available in the database. You can update the values of existing records in SQLite using the UPDATE statement.

Is it possible to access a SQLite database with Python?

I've developed two open source tools, Hindsight and SQUID, both of which use Python to access SQLite databases. I've run across a problem using Python with newer SQLite databases, and users of my tools may encounter the same problem if they are using the Python versions (the compiled versions avoid the issue).

What SQLite version do I need for partial indexing?

You need SQLite version 3.8.0 (released in 2013) or later to use the partial index features. (Quick note: the Python 3.5 installer for Windows ships with SQLite 3.8.11, but quite a few useful Python scripts are only usable with 2.x Python series.)


3 Answers

download the latest version of sqlite3.dll from sqlite website and replace the the sqlite3.dll in the python dir.

like image 190
user396159 Avatar answered Oct 12 '22 01:10

user396159


sqlite3 is not a built-in module; it's an extension module (the binary is C:\Python26\DLLs_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).

like image 29
John Machin Avatar answered Oct 12 '22 02:10

John Machin


I decided I'd just give this a shot when I realized that every library I've ever installed in python 2.6 resided in my site-packages folder. I just... copied site-packages to my 2.7 installation, and it works so far. This is by far the easiest route for me if this works -- I'll look further into it but at least I can continue to develop now.

I won't accept this answer, because it doesn't even answer my question, but it does solve my problem, as far as I can tell so far.

like image 20
Carson Myers Avatar answered Oct 12 '22 01:10

Carson Myers