Last active
April 30, 2024 05:34
-
-
Save defulmere/8b9695e415a44271061cc8e272f3c300 to your computer and use it in GitHub Desktop.
How to override an old sqlite3 module with pysqlite3 in django settings.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ⚠️ USE AT YOUR OWN RISK | |
# first: pip install pysqlite3-binary | |
# then in settings.py: | |
# these three lines swap the stdlib sqlite3 lib with the pysqlite3 package | |
__import__('pysqlite3') | |
import sys | |
sys.modules['sqlite3'] = sys.modules.pop('pysqlite3') | |
DATABASES = { | |
'default': { | |
'ENGINE': 'django.db.backends.sqlite3', | |
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), | |
} | |
} |
I tried this couple of months ago and worked, however now it doesn't. the issue is that I'm not even able to install the dependency:
pip install pysqlite3-binary ERROR: Could not find a version that satisfies the requirement pysqlite3-binary (from versions: none) ERROR: No matching distribution found for pysqlite3-binary
I saw the packages are still with the same name on pypi and they were not removed, but not sure what changed and does not work now.
Any ideas?
It also happened to me, until I realized it only works on Linux.
What do we have to do, if we are deploying on streamlit?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
worked like magic! Thank you!