Opened 9 years ago

Closed 9 years ago

Last modified 8 years ago

#26205 closed Uncategorized (needsinfo)

migrate and other commands fail with TypeError: 'NoneType' object has no attribute '__getitem__' in schema.py

Reported by: D Owned by: nobody
Component: Database layer (models, ORM) Version: 1.9
Severity: Normal Keywords: schema.py PRAGMA NonType migrate
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Only occurs with a sqlite engine where the command "PRAGMA foreign_keys" returns nothing (instead of returning 0 or 1).
This happens (at least) on sqlite3 v 3.3.6. Doesn't occur on 3.8.11.

The net effect is that the following manage.py comands fail;
migrate
makemigrations
test
plus other commands if they trigger a migration.

Changing line 25 of django/db/backends/sqlite3/schema.py from this;

self._initial_pragma_fk = c.fetchone()[0]

to this

self._initial_pragma_fk = 0  # c.fetchone()[0]

enables you to proceed with the migration.

Change History (6)

comment:1 by Simon Charette, 9 years ago

While we don't document a minimum sqlite3 version I don't think we should commit to support a version that is almost 10 years old.

I suggest we document a minimal supported version like we do with other backends.

comment:2 by D, 9 years ago

Where does the support for sqlite in django come from? Is it the sqlite module built into python (from 2.5 onwards?)?
If so, how would you upgrade it from 3.3.6 to anything newer?

Last edited 9 years ago by D (previous) (diff)

comment:3 by Claude Paroz, 9 years ago

Django uses pysqlite2 if it is installed, but most often it falls back to the sqlite3 integrated module.

On Python 2.7:

$ python2
Python 2.7.9 (default, Mar  1 2015, 12:57:24) 
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>> sqlite3.sqlite_version
'3.8.7.1'

comment:4 by Tim Graham, 9 years ago

Where do you encounter this old version of SQLite? Django only supports the latest point release of each major version of Python, so if this is with an older point release, I don't think additional documentation is necessary.

comment:5 by Tim Graham, 9 years ago

Component: UncategorizedDatabase layer (models, ORM)
Resolution: needsinfo
Status: newclosed

in reply to:  4 comment:6 by D, 8 years ago

Replying to timgraham:

Where do you encounter this old version of SQLite? Django only supports the latest point release of each major version of Python, so if this is with an older point release, I don't think additional documentation is necessary.

Tim: This occurs on SME 8.1, which is based on CentOS 5.10
https://wiki.contribs.org/SME_Server:8.1
These packages are currently available in the standard repo:

python-sqlite-1.1.7-1.2.1.0
sqlite-3.3.6-7
sqlite-devel-3.3.6-7
Note: See TracTickets for help on using tickets.
Back to Top