Opened 14 years ago

Closed 14 years ago

Last modified 13 years ago

#2944 closed defect (invalid)

With Python 2.5 dbshell launches wrong sqlite shell

Reported by: paul@… Owned by: Adrian Holovaty
Component: Core (Management commands) Version:
Severity: normal Keywords:
Cc: goldner@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description 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:

Change History (6)

comment:1 Changed 14 years ago by Michael Radziej <mir@…>

Triage Stage: UnreviewedAccepted

comment:2 Changed 14 years ago by anonymous

Cc: goldner@… added

comment:3 Changed 14 years ago by allagappan@…

I'm interested in taking up this, can someone just tell me what to do? I'm interested in getting involved with djangoproject.


comment:4 Changed 14 years ago by nick@…

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.

Or have I completely missed the point?...

comment:5 Changed 14 years ago by Paul Bx <pb@…>

Resolution: invalid
Status: newclosed

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.

comment:6 Changed 13 years ago by mir@…

My, I don't really know my reasoning when I put this into approved. So, yeah, let's keep this closed until someone can verify it.

Note: See TracTickets for help on using tickets.
Back to Top