SQLITE python 3 issue, please help
(1) By anonymous on 2020-07-30 04:14:42 [link]
I'm running into a huge issue regarding sqlite3 version in a Flask app in Mac terminal. If in my terminal I'm running sqlite3 --version, I see 3.32.3 (which is great!). However for Flask I'm using python 3.7.6, and inside my Flask code if I type ... import sqlite3 print('VERSION........', sqlite3.sqlite_version) It prints 3.24.0 (which is old). So internally python 3.7.6 is using an older sqlite3 version. I need to user at least 3.25.0 (which supports window functions). I have tried several solutions of how to resolve this issue but none successfully. Also whatever solution you suggest needs to work for our QA environment as well which is running docker in FROM python:3.7.6-buster This is driving me crazy, really appreciate for your help! PS one of the solutions I tried is to add pysqlite3==0.4.3 in my requirements.txt file and pip install that. However that didn't work either and I ran into Symbol not found: _sqlite3_enable_load_extension
(2) By David Raymond (dvdraymond) on 2020-07-30 12:59:29 in reply to 1
For Windows anyway the sqlite3 library uses sqlite3.dll found in the \Python38\DLLs folder. Is there a similar folder in a Mac installation with a shared sqlite3 library you can replace with a newer one you've compiled or downloaded yourself?
(3.1) By Tim Streater (Clothears) on 2020-07-30 13:28:59 edited from 3.0 in reply to 2 [link]
Looks like it's: /usr/lib/sqlite3 which is a soft link to /System/Library/Tcl/libtclsqlite3.dylib (at least under Mojave).
(4) By Keith Medcalf (kmedcalf) on 2020-07-30 13:37:18 in reply to 3.1 [link]
That sounds like the "system" version of the sqlite dylib, not the python side-by-each version of the library. I would expect that the side-by-deach version of the dylib used by a specific piece of software would be located somewhere within that software's tree and not linked under the systemwide /usr/lib directory structure. I could be wrong though. Last time I used a Mac they were that annoying little 6" grey monitor/box thing that crashed entertainingly with pretty bombs and sound effects every few minutes.
(5.1) By Tim Streater (Clothears) on 2020-07-30 13:54:29 edited from 5.0 in reply to 4 [link]
Yes, but if the OP can find where the Python version is, he can save the one that's there, and then copy the one I indicated to that spot. The version that the CLI has is: SQLite version 3.28.0 2019-04-16 19:49:53 The CLI seems to be over a meg so I'm assuming the library is built in, possibly with different compile-time options than the .dylib. These are the versions that come with Mojave, anyway.
(6) By anonymous on 2020-08-01 02:50:16 in reply to 5.1 [link]
My python 3.7/sqlite3 folder has 4 things 1) test (folder) 2) __init__.py 3) dbapi2.py 4) dump.py How can I upgrade this so I get sqlite3 3.25.0 or above?
(7) By anonymous on 2020-08-01 02:56:48 in reply to 5.1 [link]
I have something called Typeshed Stubs, and there is a folder sqlite3 which has __init__.pyi and dbapi2.pyi inside init is has from sqlite3.dbapi2 import * # noqa: F403, FYI
(8) By anonymous on 2020-08-01 05:08:46 in reply to 7 [link]
guys I have been able to solve this problem by installing python with sqlite flag PYTHON_CONFIGURE_OPTS="LD_RUN_PATH=/usr/local/opt/sqlite/lib LDFLAGS=-L/usr/local/opt/sqlite/lib CPPFLAGS=-I/usr/local/include" pyenv install <PYTHON_VERSION>