Install newer version of sqlite3 on AWS Lambda

Viewed 404

I want to use Window functions on sqlite3 on my python3.8 code running on AWS Lambda. They are available since version 3.25.

Unfortunately, on AWS Lambda Python3.8, sqlite3 library is outdated:

>>> sqlite3.sqlite_version
'3.7.17'

while locally, on my homebrew install of Python3.8: (working)

>>> import sqlite3
>>> sqlite3.sqlite_version
'3.31.1'

How can I get an sqlite3 version > 3.25 on AWS Lambda Python 3.8 ?

1 Answers

I found a way: I used the external package pysqlite3, in the binary version.

in my requirements.txt

pysqlite3-binary==0.4.4

in the code

try:
    import pysqlite3 as sqlite3
except ModuleNotFoundError:
    import sqlite3  # for local testing because pysqlite3-binary couldn't be installed on macos
Related