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 Distribution

sqlean.py-3.45.1.tar.gz (3.2 MB view hashes)

Uploaded Source

Built Distributions

sqlean.py-3.45.1-cp312-cp312-win_arm64.whl (704.7 kB view hashes)

Uploaded CPython 3.12 Windows ARM64

sqlean.py-3.45.1-cp312-cp312-win_amd64.whl (783.0 kB view hashes)

Uploaded CPython 3.12 Windows x86-64

sqlean.py-3.45.1-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-3.45.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.9 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARM64

sqlean.py-3.45.1-cp312-cp312-macosx_11_0_arm64.whl (919.9 kB view hashes)

Uploaded CPython 3.12 macOS 11.0+ ARM64

sqlean.py-3.45.1-cp312-cp312-macosx_10_9_x86_64.whl (952.6 kB view hashes)

Uploaded CPython 3.12 macOS 10.9+ x86-64

sqlean.py-3.45.1-cp311-cp311-win_arm64.whl (704.1 kB view hashes)

Uploaded CPython 3.11 Windows ARM64

sqlean.py-3.45.1-cp311-cp311-win_amd64.whl (781.9 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

sqlean.py-3.45.1-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-3.45.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.9 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

sqlean.py-3.45.1-cp311-cp311-macosx_11_0_arm64.whl (920.0 kB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

sqlean.py-3.45.1-cp311-cp311-macosx_10_9_x86_64.whl (952.9 kB view hashes)

Uploaded CPython 3.11 macOS 10.9+ x86-64

sqlean.py-3.45.1-cp310-cp310-win_arm64.whl (704.1 kB view hashes)

Uploaded CPython 3.10 Windows ARM64

sqlean.py-3.45.1-cp310-cp310-win_amd64.whl (781.9 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

sqlean.py-3.45.1-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-3.45.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.9 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

sqlean.py-3.45.1-cp310-cp310-macosx_11_0_arm64.whl (919.3 kB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

sqlean.py-3.45.1-cp310-cp310-macosx_10_9_x86_64.whl (951.8 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

sqlean.py-3.45.1-cp39-cp39-win_arm64.whl (704.1 kB view hashes)

Uploaded CPython 3.9 Windows ARM64

sqlean.py-3.45.1-cp39-cp39-win_amd64.whl (782.0 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

sqlean.py-3.45.1-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-3.45.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.9 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

sqlean.py-3.45.1-cp39-cp39-macosx_11_0_arm64.whl (919.2 kB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

sqlean.py-3.45.1-cp39-cp39-macosx_10_9_x86_64.whl (951.5 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

sqlean.py-3.45.1-cp38-cp38-win_amd64.whl (782.1 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

sqlean.py-3.45.1-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-3.45.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.9 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

sqlean.py-3.45.1-cp38-cp38-macosx_11_0_arm64.whl (918.9 kB view hashes)

Uploaded CPython 3.8 macOS 11.0+ ARM64

sqlean.py-3.45.1-cp38-cp38-macosx_10_9_x86_64.whl (951.1 kB view hashes)

Uploaded CPython 3.8 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