Sqlean.py
Python's sqlite3 + extensions
Install / Use
/learn @nalgeon/Sqlean.pyREADME
sqlean.py
This package provides an SQLite Python wrapper bundled with sqlean extensions. It's a drop-in replacement for the standard library's sqlite3 module.
The project is no longer maintained.
pip install sqlean.py
import sqlean
# enable all extensions
sqlean.extensions.enable_all()
# has the same API as the default sqlite3 module
conn = sqlean.connect(":memory:")
conn.execute("create table employees(id, name)")
# and comes with sqlean extensions
cur = conn.execute("select median(value) from generate_series(1, 99)")
print(cur.fetchone())
# (50.0,)
conn.close()
Extensions
sqlean.py contains essential SQLite extensions:
- crypto: Hashing, encoding and decoding data
- define: User-defined functions and dynamic SQL
- fileio: Reading and writing files
- fuzzy: Fuzzy string matching and phonetics
- ipaddr: IP address manipulation
- regexp: Regular expressions
- stats: Math statistics
- text: String functions
- time: High-precision date/time
- uuid: Universally Unique IDentifiers
- vsv: CSV files as virtual tables
Installation
pip install sqlean.py
Note that the package name is sqlean.py, while the code imports are just sqlean. The sqlean package name was taken by some zomby project and the author seemed to be unavailable, so I had to add the .py suffix.
A binary package (wheel) is available for the following operating systems:
- Linux (x86_64/aarch64)
- macOS (x86_64/arm64)
Unfortunately, there are no wheels available for Windows.
Usage
All extensions are disabled by default. You can still use sqlean as a drop-in replacement for sqlite3:
import sqlean as sqlite3
conn = sqlite3.connect(":memory:")
cur = conn.execute("select 'sql is awesome'")
print(cur.fetchone())
conn.close()
To enable all extensions, call sqlean.extensions.enable_all() before calling connect():
import sqlean
sqlean.extensions.enable_all()
conn = sqlean.connect(":memory:")
cur = conn.execute("select median(value) from generate_series(1, 99)")
print(cur.fetchone())
conn.close()
To enable specific extensions, call sqlean.extensions.enable():
import sqlean
sqlean.extensions.enable("stats", "text")
conn = sqlean.connect(":memory:")
cur = conn.execute("select median(value) from generate_series(1, 99)")
print(cur.fetchone())
conn.close()
Building from source
Prepare source files:
make prepare-src
make download-sqlite
make download-sqlean
Build and test the package:
make clean build
Credits
Based on the pysqlite3 project. Available under the Zlib license.
Related Skills
claude-opus-4-5-migration
84.7kMigrate prompts and code from Claude Sonnet 4.0, Sonnet 4.5, or Opus 4.1 to Opus 4.5
model-usage
342.0kUse CodexBar CLI local cost usage to summarize per-model usage for Codex or Claude, including the current (most recent) model or a full model breakdown. Trigger when asked for model-level usage/cost data from codexbar, or when you need a scriptable per-model summary from codexbar cost JSON.
feishu-drive
342.0k|
things-mac
342.0kManage Things 3 via the `things` CLI on macOS (add/update projects+todos via URL scheme; read/search/list from the local Things database)
