A SQLAlchemy driver for sqlean.py
.
Table of Contents
pip install sqlean-driver
from sqlalchemy import create_engine, func, select
engine = create_engine("sqlite+sqlean:///:memory:?extensions=all")
with engine.connect() as conn:
result = conn.execute(select(func.ipfamily("192.168.1.1")))
print(result.scalar()) # 4
By default, sqlean.py
disables all SQLite extensions. To enable all of them, pass extensions=all
as a query parameter to the connection string. Or use a comma-separated list of extensions to enable only some of them, e.g. extensions=ipaddr,crypto
.
Note that you don't strictly need this driver to use sqlean.py
with SQLAlchemy. You can supply sqlean
as the module
parameter to create_engine
:
import sqlean
from sqlalchemy import create_engine, func, select
sqlean.extensions.enable_all()
engine = create_engine("sqlite:///:memory:", module=sqlean)
with engine.connect() as conn:
result = conn.execute(select(func.ipfamily("192.168.1.1")))
print(result.scalar()) # 4
This project uses Hatch to manage the development environment, so make sure you have it installed.
Run tests and compute coverage for all supported Python and SQLAlchemy versions:
hatch run test:cov
Combine coverage output into a single report:
hatch run coverage:report
hatch run lint:style
hatch run typing:check
sqlean-driver
is distributed under the terms of the MIT license.
- Anton Zhiyanov for creating
sqlean
andsqlean.py
. - Orhun Parmaksız for creating
git-cliff
, which this project uses to keep a changelog.