Forums

Upgrading SQLite for Django 2.2

I've installed Django 2.2, on to a virtualenv using Python 3.6 The minimum supported version of SQLite is now 3.8.3 https://docs.djangoproject.com/en/2.2/releases/2.2/

When I run tests I get the following error:

django.core.exceptions.ImproperlyConfigured: SQLite 3.8.3 or later is required (found 3.8.2).

Checking the version of SQLite shows that it no longer satisfies the minimum requirement for Django 2.2

>>> import sqlite3
>>> sqlite3.sqlite_version
'3.8.2'

Is there an easy way to upgrade the version of SQLite on PythonAnywhere?

There's a reasonably easy way :-) The version of SQLite you have installed depends on the system image associated with your account; you're on our older "dangermouse" system image, and the new "earlgrey" image has SQLite version 3.11.0. We can easily switch your account over to "earlgrey" -- it's just a simple database change on our side.

But there is one catch; the versions of many other things will be upgraded at the same time. For example, Python 2.7.6 will be upgraded to 2.7.12, Python 3.6.0 will be upgraded to 3.6.6, and so on -- and also many of the pre-installed Python modules will be upgraded. The latter means that any code you have that depends on the older versions of the pre-installed modules may break if it's not compatible with any API changes. The former is a little more subtle -- virtualenvs can have issues with point release upgrades, so ones that were built for (eg) Python 2.7.6 are not always compatible with 2.7.12 -- so you might need to re-create any virtualenvs.

Anyway, we can certainly switch you over to the "earlgrey" image if you like -- just let us know.

Yes that would be great if I could get upgraded!

I am facing similar problem. But I hold a free account with pythonanywhere.com. Any chances of SQlite upgrades from your end for free users to support DJango 2.2? If not, what do you suggest as an alternative solution?

Switching images is not limited to paying accounts. Just send feedback requesting the change.

Thanks Glenn, I have sent feedback from my 2 accounts (anykate.pythonanywhere.com & aniket31.pythonanywhere.com) requesting the upgrade of SQLite3 version to 3.8.3 OR above. However, I cannot see the feedback that I posted anywhere in my account(s). Hope Pythonanywhere team has received the same. Thank you so much for your help.

@anykate -- we've received the messages, and that's done now for both of those accounts. Any new consoles you start will have the new system image; any scheduled/always-on tasks and websites will pick it up the next time they're (re)started. Do note the warning above about virtualenvs -- you may need to rebuild them due to the point release changes in the versions of Python.

(Also, for completeness -- it looks like one of my colleagues switched @justinhui over yesterday. I suspect that they sent an email about that, but just in case...)

Can you please switch mine too?

Ok. That's done.

Mine also? Please and thank you!

hi there- can you send us a feedback message from your account confirming that you understand that this may break your code and you will have to recreate your virtualenvs? We will switch you over after that.

Can you please switch mine too?

hi there- can you send us a feedback message from your account confirming that you understand that this may break your code and you will have to recreate your virtualenvs? We will switch you over after that.

Its ok. I understand. Upgrade for ko0n.pythonanywhere.com please.

Thank you

ok, done that.

I've been able to get a workaround for the error by including the previous WSGI config default in my dspeights_pythonanywhere_com_wsgi:

from django.core.wsgi import get_wsgi_application

application = get_wsgi_application()

# or, for older django <=1.4

import django.core.handlers.wsgi

application = django.core.handlers.wsgi.WSGIHandler()

Is there a downside to using this work-around? I am only using Python3 ENVs, so I would be comfortable either way.

Thanks!

I'm a bit confused what work around you used. And was the error for this sqlite version problem?

Sorry, I could have been clearer! Here is the link for the tutorial doc that I used a while back: - https://help.pythonanywhere.com/pages/DeployExistingDjangoProject/

The Edit your WSGI file step has a code snippet, which includes a #commented# code block which says:

##### or,  for older Django <=1.4    
##### or,  for older Django <=1.4
#import django.core.handlers.wsgi
#application = django.core.handlers.wsgi.WSGIHandler()

Removing the comments from those lines resolved the SQLite 3.8.3 or later is required error I also received (on a django 2.2 project). I am not sure if this is a good work-around, for not having to upgrade, or if it would be better to switch?

Thank you for your assistance!

Honestly, I'm a little surprised that that even worked. Are you sure that you're actually running Django 2.2 and not accidentally running an older version?

I believe so?:

(ff_env) 17:48 ~/ff_core (master)$ pip freeze
-f /usr/share/pip-wheels
configparser==3.7.4
Django==2.2
mysqlclient==1.4.2.post1
pytz==2019.1
sqlparse==0.3.0
(ff_env) 17:48 ~/ff_core (master)$

...

(ff_env) 17:51 ~/ff_core/ff_web (master)$ ./manage.py shell
Python 3.6.0 (default, Jan 13 2017, 00:00:00) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import django
>>> django.VERSION
(2, 2, 0, 'final', 0)

EDIT - also, here's my django-generated settings note:

(ff_env) 17:56 ~/ff_core/ff_web (master)$ cat ff_web/settings.py 
"""
Django settings for ff_web project.
Generated by 'django-admin startproject' using Django 2.2.
For more information on this file, see
https://docs.djangoproject.com/en/2.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.2/ref/settings/
"""

wait- I see that you have mysqlclient installed. Are you using sqlite or mysql? If you are now using mysql, then you shouldn't have to deal with any sqlite version issues.

That seems to be it! The settings file configuration is specifying mysql on the server (because of the error, I would assume), and sqlite for local development, from what I can see?

if '/home/dspeights/' in BASE_DIR:
...
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        ...
elif '/.../.../' in BASE_DIR:
...
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
...

I appreciate the help discovering the issue! Is there a date set for when SQLite 3.8.3 will be made? It seems like it will require changes, but would allow my dev and prod environments to be consistent... I have a few projects pending in the pipeline which may require sqlite, but nothing immediate.

Side note: Thanks for providing such a great service! You guys are a critical part of my business model!

The new version is already available, we just need to switch your account to a new system image.

Switching to the new version may break some of your existing code that worked on older versions. You may need to recreate any virtualenvs that you're using and you will need to start new consoles and reload your web apps.

Let us know if you'd like to switch your system image for you.

Pinged feedback for the same reason - thanks to this thread, made it really easy to diagnose. :)

Hy. Can you switch mine too? I don't mind the risks. Thanks

No problem. I have updated your account.

Hi glenn, It's possible to upgrade mine too?

No problem, rafarosante. That's done.

Hi glenn, could you please upgrade mine too? I'm aware of the risk that might be produced due to the upgrade of python and its modules.

By the way, is there any button from my or your side to reset my account? I have some old files and I would like to clean up and start over, so I don't drag any old file or config to this upgrade... just in case :).

I don't mind losing files, everything that is important is already downloaded in my pc.

Thanks.

P.S: Is this enough or I should send feedback for this?

Hi enderlook -- I've switched you over to the new system image. We don't have an easy way to reset your account, but if you like we can completely delete it -- then you can sign up again using the same username, so the net effect will be the same as resetting the account. If you'd like us to do that, use the send feedback link to send us a message to that effect.

Ok, but, if they delete my account and then I make a new one, would I have to ask again about the switch or new accounts are already using the new system image by default?

New accounts get the most recent system image by default.

Hi glenn, could you upgrade mine too? i don't care about the risk

No problem. That's done.

Hi,

Just found this thread since I also stumbled on the same issue :) Would be very nice if my account also was upgraded. Thanks!

Hi, Could I have my account upgraded as well. Been working on my test server on my computer which was django 2 and want to just git pull it over.

Thanks!

@Joeriksson, @johnreilly -- before we switch you over, could you confirm that you've read the warning above?

Hi, can I please get switched to the new server as well??

@fdelacruz -- before we switch you over, could you confirm that you've read the warning above?

@giles I confirm I've read the warning :D I'm 100% a-okay with all the pre-installed python modules being upgraded. Thank you very much in advance! :D

I confirm I read the warning. I have nothing in my account right now that is important.

@giles any chance this can get done today? Thank you :)

@Joeriksson, @johnreilly -- no problem, that's done now. Any new consoles you start will have the new system image. Websites, scheduled tasks, and always-on tasks will pick it up the next time they're restarted.

Thank you very much @giles!

Please can you switch my account to the new system image, i have read all the warnings above and I need the new database version to migrate my code in from git. Thank you.

okay, we've switched that for you!

Hi, can you switch my account too? I have read all the warnings from you. @giles @conrad

@BeAsY -- no problem, that's done now. Any new consoles you start will have the new system image. Websites, scheduled tasks, and always-on tasks will pick it up the next time they're restarted.

Hello @giles, Could you upgrade mine account also? Thanks

Hi glenn and giles, It's possible to upgrade mine too? Thank you in advance

@jrcki, @blackat87 -- before we switch you over, could you confirm that you've read the warning above?

@giles Hi giles, yes I've read all the warnings

@blackat87 no problem. That's done. Happy coding!

@giles Hi Giles, could you change image to "earlgrey" for my account please?

@giles Hi Giles, could you change image to "earlgrey" for my account please?

@codepriest -- before we switch you over, could you confirm that you've read the warning above?

@giles yes sure, I'm aware about possible consequences.

No problem. That's done.

@giles @ glenn Thank you guys!

Could you change image to "earlgrey" for my account please? I have read all the warnings above. I'm having SQLite version problem as mentioned.

No problem. That's done.

Could you change image to "earlgrey" for my account please? I have read all the warnings above. I'm having SQLite version problem as mentioned.

Sure. I have switched your account.

Can you please update my account, too?

@gloriahigley -- before we switch you over, could you confirm that you've read the warning above?

I have. And I'm nervous but let's please proceed. :)

@gloriahigley no problem :-) That's done now. Any new consoles you start will have the new system image; websites and scheduled/always-on tasks will pick it up the next time they're started. If you need it switched back, just let us know.

Could you please update my account? Have this nasty sqlite 3.8.3 requiring error

@isaakbormental -- before we switch you over, could you confirm that you've read the warning above?

Hello @giles Could you update my account to? I have the same error with sqlite.

No problem. I have updated your account.

Thank you @glenn

Hi. Could you upgrade my account too? I have the same error with sqlite.

@stayathomegeek -- before we switch you over, could you confirm that you've read the warning above?

Yes I agree to the warnings. In addition to the sqlite update, I also need python 3.7. I have read the warning here and on other pages and understand about code changes and virtualenv changes. Please proceed. Thanks so much!

No problem. I have update your account.

@glenn Thanks for doing the updates. I have now re-created my virtualenv, but ended up with a message on my web tab page: "This virtualenv seems to have the wrong Python version (3.7 instead of 3.6)." Can you tell me how to correct this? I expect to be running Python 3.7. I don't know how to figure this out. Thank you.

Delete the virtualenv and re-create it with the version of Python that your web app is configured for.

I did exactly that. That's why I'm confused about this. I already removed it and then re-created it with 3.7. I will do it all over again, but in the meantime, could there be another reason for the message? Thanks!

So I deleted the virtualenv for the second time, and then re-created it with Python 3.7. I see that it is correct in the bash console:

(venv) 18:20 ~/SiteEvents (master)$ python -V
Python 3.7.0
(venv) 18:21 ~/SiteEvents (master)$

But when I do a reload, I still see the error message in my web tab, under Virtualenv:

This virtualenv seems to have the wrong Python version (3.7 instead of 3.6).

I just now also went to the code section of the web app, and updated Python 3.6 to 3.7 there. But when I reload, it still throws the same error as always. (Here's what I followed to find out I had to update the Python version in the code section: https://www.pythonanywhere.com/forums/topic/3002/)

Okay it looks like I had initially created a virtualenv in a different location than where I created the new one. That seems to be the reason for the error message. I have now deleted the unwanted virtualenv, and all is well. I hope my afternoon of debugging as a newb will help some other newb LOL: If you're trying to update sql, and you have to re-create your virtualenv, be sure you end up with only ONE virtualenv.

:) thanks for detailing your journey, hope it will be useful to others reading the thread!

Any way I can get my SQLite updated too? I have run in the same issue with my Django app. django.core.exceptions.ImproperlyConfigured: SQLite 3.8.3 or later is required (found 3.8.2).

before we switch you over, could you confirm that you've read the warning above?

I have read the warning and agree. Thank you for the help.

Okay, we have switched you over to the new image. You will have to restart your consoles, webapps and always on tasks for the chg to take effect.

can i be switched over too please? Having the same problem. Thanks

I have read the warnings

@perks3 okay, we have switched you over the the new image. You will have to restart your consoles, webapps and always on tasks for the chg to take effect.

Could you update my account? I have read the warning and accept the risks.

Thank you for reading

No problem -- that's done now. Any new consoles you start will have the new system image; websites and scheduled/always-on tasks will pick it up the next time they're started. If you need it switched back, just let us know.

Hello! can i be switched over too please? Having the same problem. I have read the warnings. Thanks

Sure! That's done now. As we said before, any new consoles you start will have the new system image; websites and scheduled/always-on tasks will pick it up the next time they're started. If you need it switched back, just let us know.

Hi! Please switch me over too! Things are already broken, so it's okay if they break some more. Thanks!

Okay, I have changed that for you. You will need to re-create any virtualenvs. Any new consoles you start will have the new system image; websites and scheduled/always-on tasks will pick it up the next time they're started.