Skip to content

Instantly share code, notes, and snippets.

@defulmere
Last active December 16, 2024 17:20
Show Gist options
  • Save defulmere/8b9695e415a44271061cc8e272f3c300 to your computer and use it in GitHub Desktop.
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
# ⚠️ 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'),
}
}
@sureGU
Copy link

sureGU commented Sep 5, 2024

You do not need to modify anything. To bypass the Colab check, you can create an empty folder google/colab in the site packages folder. That way on the Chroma __init__.py when it tries to do the import google.colab check it will pass, and thus replace sqlite3 with pysqlite3

This worked for me!!

worked for me too

@vedprakashnautiyal
Copy link

What do we have to do, if we are deploying on streamlit?

Hey did you solve this issue ?

@vedprakashnautiyal
Copy link

Hey, so I was able to bypass this issue by just adding pysqlite3-binary to requirements.txt

Did not have to add any versioning, or other code.

Hey, were you deploy on the cloud, I wanted to deploy on streamlit, but error persist even after adding it to the requirement file

@blacknred0
Copy link

same problem here in streamlit community cloud

@Sagor0078
Copy link

raise RuntimeError(
RuntimeError: Your system has an unsupported version of sqlite3. Chroma requires sqlite3 >= 3.35.0.

how to solve this issue?

@blacknred0
Copy link

It seems like they know the issue. It just matters on them upgrading the Debian OS from bullseye to bookworm https://discuss.streamlit.io/t/debian-11-eol/80690/7

@aiqbal77
Copy link

aiqbal77 commented Nov 9, 2024

This seemed to work for me:

  1. Download the Latest SQLite Source:
    wget https://www.sqlite.org/2023/sqlite-autoconf-3430100.tar.gz

  2. Extract the Downloaded File:
    tar -xvf sqlite-autoconf-3430100.tar.gz
    cd sqlite-autoconf-3430100

  3. Build and Install SQLite:
    ./configure
    make
    sudo make install

  4. Verify the Installation:
    After installation, confirm that the new version is available:
    sqlite3 --version

  5. Verify in Python:
    Ensure that Python picks up the updated SQLite version:

python -c "import sqlite3; print(sqlite3.sqlite_version)"

@sdubal
Copy link

sdubal commented Nov 14, 2024

thanks, worked for me.

@JGallegoPerez
Copy link

import('pysqlite3')
import sys
sys.modules['sqlite3'] = sys.modules.pop('pysqlite3')

Worked perfectly for me too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment