Skip to main content

SQLAlchemy dialect for the sqlean.py SQLite wrapper

Project description

sqlean-driver

PyPI - Version PyPI - Python Version

A SQLAlchemy driver for sqlean.py.


Table of Contents

Installation

pip install sqlean-driver

Usage

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

Extensions

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.

Alternatives

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

Development

This project uses Hatch to manage the development environment, so make sure you have it installed.

Run tests and coverage

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

Run linter

hatch run lint:style

Run type checker

hatch run typing:check

License

sqlean-driver is distributed under the terms of the MIT license.

Acknowledgements

Download files

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

Source Distribution

sqlean_driver-0.1.1.tar.gz (12.3 kB view hashes)

Uploaded Source

Built Distribution

sqlean_driver-0.1.1-py3-none-any.whl (4.6 kB view hashes)

Uploaded Python 3

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