Code

Opened 8 years ago

Closed 7 years ago

Last modified 7 years ago

#2944 closed defect (invalid)

With Python 2.5 dbshell launches wrong sqlite shell

Reported by: paul@… Owned by: adrian
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: UI/UX:

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:

http://docs.python.org/dev/lib/complete_statement.txt

Attachments (0)

Change History (6)

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

  • Component changed from Tools to django-admin.py
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 7 years ago by anonymous

  • Cc goldner@… added

comment:3 Changed 7 years ago by allagappan@…

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

Thanks,
Alagu
alagu.net

comment:4 Changed 7 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 7 years ago by Paul Bx <pb@…>

  • Resolution set to invalid
  • Status changed from new to closed

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 7 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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.