Description

manage.py dbshell launches the sqlite on the command line. But the chances of this being the same version as Python 2.5's embedded one are fairly slim. Unfortunately the file format is different between versions so the shell for one version is not necessarily compatible with the Python version. There should be some check of the form:

os.popen("sqlite3 -version").read().strip("\n") == sqlite3.version

In this case, perhaps Django should fall back to this pseudo-shell thing:

I'm not sure exactly what the problem is here. As I understand it, Python's sqlite3 module is merely a wrapper around an external SQLite library, presumably the same one being used by the sqlite3 command-line program.

The suggested test is likely to be always false because executing sqlite3 -version in a shell gives you the version number of the underlying SQLite installation whereas sqlite3.version in a Python environment gives you the version number of the wrapper, and the two version numbers are unrelated.

I'm confused by the request as well (and I'm the one who created the original "dbshell" command).

As Nick notes, there are two pieces to using SQLite with Python: DB-API modules, and the SQLite C library. (The command-line SQLite client interacts with the library and has nothing to do with Python per se.)

Python 2.5 ships with SQLite *bindings* in the form of a "sqlite3" DB-API module in the standard library. This means you no longer need the third-party "pysqlite2" DB-API module. But *both* of those modules require that you have version 3 of the SQLite binary (library) installed on your machine.

Django already has code that takes care of doing the right import depending on your Python version.

Confusingly, the "2" in the name of the "pysqlite2" module refers not to SQLite 2 (which does have a different file format from SQLite 3), but presumably to the fact that it's the second major version of the pysqlite module. Both the pysqlite2 module and the new sqlite3 module talk to SQLite version 3 only.

I'm marking this as "invalid" for now; please reopen with clarification if we have misunderstood.