0

I have a Django application that has been working just fine. Then I get errors on some updates. They are all of the form:

no such table: main.event_contestant__old

My environment is Python 3.7.2, Django 2.1.5 on MacOs 10.12.6

After a couple of days searching around, this appears to be a bug caused by some incompatibility between Django and sqlite3 V2.6 (v3.26).

I have tried Django versions 2.0.7, 2.1.5 and 2.1.7 but the errors persist so, whatever was done in Django 2.1.5 that was supposed to fix the bug is not effective.

Further reading indicates that the bug arrived with sqlite 2.6.0 and that older versions of python used an older version of sqlite3. So I changed my python version to 3.5 but the version of sqlite has not changed.

My question is - why does the sqlite version not change when I use a different version of python?

UPDATE:

Install python 3.5.4 from python.org

Create a virtual environment for python 3.5.4 and run this

Python 3.5.4 (v3.5.4:3f56838976, Aug  7 2017, 12:56:33) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>> sqlite3.version
'2.6.0'
>>> sqlite3.sqlite_version
'3.8.11'
>>> 

Do the same for python 3.6.5:

Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 05:52:31) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>> sqlite3.version
'2.6.0'
>>> sqlite3.sqlite_version
'3.22.0'
>>>  

Once more with python 3.7.2 to get

Python 3.7.2 (v3.7.2:9a3ffc0492, Dec 24 2018, 02:44:43) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>> sqlite3.version
'2.6.0'
>>> sqlite3.sqlite_version
'3.22.0'
>>>

OK. It looks like I have togo back to python 3.5.4 to get a different version of sqlite3 but the actual version is indeed changing with different Python installs.

Now I need to test those versions agains my bug in Django.

I have answered my question below to indicate this update. Probably, I will be back with questions about the Django thing.

Peter Harrison
  • 367
  • 1
  • 3
  • 15
  • Does Python use its own copy of the sqlite library or does it just use whatever version your OS has installed? – Shawn Feb 22 '19 at 14:43
  • Good question. I am not sure how to find out. – Peter Harrison Feb 22 '19 at 14:55
  • I don't know either (I don't use python), but finding out will go a long ways towards answering the question. – Shawn Feb 22 '19 at 14:59
  • Relevant [python-3-5-update-sqlite3-version](https://stackoverflow.com/questions/54382087/python-3-5-update-sqlite3-version) and [force-python-to-forego-native-sqlite3-and-use-the-installed-latest-sqlite3-ver](https://stackoverflow.com/questions/1545479/force-python-to-forego-native-sqlite3-and-use-the-installed-latest-sqlite3-ver) – stovfl Feb 22 '19 at 15:20
  • Thank you. Your comment arrived while I was typing my update. I will have a look. – Peter Harrison Feb 22 '19 at 16:04

1 Answers1

0

The short answer is that Python does indeed install different versions of sqlite. My problem was that I was confusing the old style version numbers (like sqlite.version => 2.6.0) with the newer versioning (like sqlite.sqlite_version => 3.8.11).

I have updated the question to show how to get the version numbers and the differences between three recent Python 3 releases.

Peter Harrison
  • 367
  • 1
  • 3
  • 15