Skip to main content

sqlite3 with extensions

Project description

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.

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 the `sqlean` extensions
cur = conn.execute("select median(value) from generate_series(1, 99)")
print(cur.fetchone())
# (50.0,)

conn.close()

Extensions

sqlean.py contains 12 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
  • math: Math functions
  • regexp: Regular expressions
  • stats: Math statistics
  • text: String functions
  • unicode: Unicode support
  • uuid: Universally Unique IDentifiers
  • vsv: CSV files as virtual tables

Installation

A binary package (wheel) is available for the following operating systems:

  • Windows (64-bit)
  • Linux (64-bit)
  • macOS (both Intel and Apple processors)
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.

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

For development purposes only.

Prepare source files:

make prepare-src
make download-sqlite
make download-sqlean

Build and test the package:

make clean
python setup.py build_ext -i
python -m test
python -m pip wheel . -w dist

Credits

Based on the pysqlite3 project. Available under the Zlib license.

Stay tuned

Subscribe to stay on top of new features 🚀

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

sqlean.py-0.21.8.4-cp312-cp312-win_arm64.whl (723.6 kB view hashes)

Uploaded CPython 3.12 Windows ARM64

sqlean.py-0.21.8.4-cp312-cp312-win_amd64.whl (770.5 kB view hashes)

Uploaded CPython 3.12 Windows x86-64

sqlean.py-0.21.8.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.9 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

sqlean.py-0.21.8.4-cp312-cp312-macosx_11_0_arm64.whl (906.9 kB view hashes)

Uploaded CPython 3.12 macOS 11.0+ ARM64

sqlean.py-0.21.8.4-cp312-cp312-macosx_10_9_x86_64.whl (938.6 kB view hashes)

Uploaded CPython 3.12 macOS 10.9+ x86-64

sqlean.py-0.21.8.4-cp311-cp311-win_arm64.whl (723.1 kB view hashes)

Uploaded CPython 3.11 Windows ARM64

sqlean.py-0.21.8.4-cp311-cp311-win_amd64.whl (769.4 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

sqlean.py-0.21.8.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.9 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

sqlean.py-0.21.8.4-cp311-cp311-macosx_11_0_arm64.whl (907.1 kB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

sqlean.py-0.21.8.4-cp311-cp311-macosx_10_9_x86_64.whl (938.6 kB view hashes)

Uploaded CPython 3.11 macOS 10.9+ x86-64

sqlean.py-0.21.8.4-cp310-cp310-win_arm64.whl (723.1 kB view hashes)

Uploaded CPython 3.10 Windows ARM64

sqlean.py-0.21.8.4-cp310-cp310-win_amd64.whl (769.4 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

sqlean.py-0.21.8.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.9 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

sqlean.py-0.21.8.4-cp310-cp310-macosx_11_0_arm64.whl (905.6 kB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

sqlean.py-0.21.8.4-cp310-cp310-macosx_10_9_x86_64.whl (937.4 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

sqlean.py-0.21.8.4-cp39-cp39-win_arm64.whl (723.1 kB view hashes)

Uploaded CPython 3.9 Windows ARM64

sqlean.py-0.21.8.4-cp39-cp39-win_amd64.whl (769.6 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

sqlean.py-0.21.8.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.9 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

sqlean.py-0.21.8.4-cp39-cp39-macosx_11_0_arm64.whl (905.3 kB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

sqlean.py-0.21.8.4-cp39-cp39-macosx_10_9_x86_64.whl (937.1 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

sqlean.py-0.21.8.4-cp38-cp38-win_amd64.whl (769.6 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

sqlean.py-0.21.8.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.9 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

sqlean.py-0.21.8.4-cp38-cp38-macosx_11_0_arm64.whl (904.8 kB view hashes)

Uploaded CPython 3.8 macOS 11.0+ ARM64

sqlean.py-0.21.8.4-cp38-cp38-macosx_10_9_x86_64.whl (936.5 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

sqlean.py-0.21.8.4-cp37-cp37m-win_amd64.whl (769.3 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

sqlean.py-0.21.8.4-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.9 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

sqlean.py-0.21.8.4-cp37-cp37m-macosx_10_9_x86_64.whl (935.7 kB view hashes)

Uploaded CPython 3.7m macOS 10.9+ x86-64

sqlean.py-0.21.8.4-cp36-cp36m-win_amd64.whl (769.5 kB view hashes)

Uploaded CPython 3.6m Windows x86-64

sqlean.py-0.21.8.4-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.9 MB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.17+ x86-64

sqlean.py-0.21.8.4-cp36-cp36m-macosx_10_9_x86_64.whl (936.0 kB view hashes)

Uploaded CPython 3.6m macOS 10.9+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page