Metadata-Version: 2.1
Name: sqlean-driver
Version: 0.1.1
Summary: SQLAlchemy dialect for the sqlean.py SQLite wrapper
Project-URL: Changelog, https://github.com/edgarrmondragon/sqlean-driver/blob/main/CHANGELOG.md
Project-URL: Documentation, https://github.com/edgarrmondragon/sqlean-driver#readme
Project-URL: Issues, https://github.com/edgarrmondragon/sqlean-driver/issues
Project-URL: Source, https://github.com/edgarrmondragon/sqlean-driver
Author-email: Edgar Ramírez Mondragón <edgarrm358@gmail.com>
Maintainer-email: Edgar Ramírez Mondragón <edgarrm358@gmail.com>
License-Expression: MIT
License-File: LICENSE.txt
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Education
Classifier: Intended Audience :: Information Technology
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: SQL
Classifier: Topic :: Database
Classifier: Topic :: Software Development
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.8
Requires-Dist: sqlalchemy>=1.4
Requires-Dist: sqlean-py>=0.21.5.1
Provides-Extra: dev
Requires-Dist: pytest; extra == 'dev'
Description-Content-Type: text/markdown

# sqlean-driver

[![PyPI - Version](https://img.shields.io/pypi/v/sqlean-driver.svg)](https://pypi.org/project/sqlean-driver)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/sqlean-driver.svg)](https://pypi.org/project/sqlean-driver)

A SQLAlchemy driver for [`sqlean.py`](https://github.com/nalgeon/sqlean.py).

-----

**Table of Contents**

- [Installation](#installation)
- [Usage](#usage)
  - [Extensions](#extensions)
  - [Alternatives](#alternatives)
- [Development](#development)
  - [Run tests and coverage](#run-tests-and-coverage)
  - [Run linter](#run-linter)
  - [Run type checker](#run-type-checker)
- [License](#license)
- [Acknowledgements](#acknowledgements)

## Installation

```console
pip install sqlean-driver
```

## Usage

```python
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](https://github.com/nalgeon/sqlean.py#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`](https://docs.sqlalchemy.org/en/20/core/engines.html#sqlalchemy.create_engine.params.module) parameter to `create_engine`:

```python
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](https://hatch.pypa.io/) 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:

```shell
hatch run test:cov
```

Combine coverage output into a single report:

```shell
hatch run coverage:report
```

### Run linter

```shell
hatch run lint:style
```

### Run type checker

```shell
hatch run typing:check
```

## License

`sqlean-driver` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.

## Acknowledgements

* [Anton Zhiyanov](https://github.com/nalgeon) for creating [`sqlean`](https://github.com/nalgeon/sqlean) and [`sqlean.py`](https://github.com/nalgeon/sqlean.py).
* [Orhun Parmaksız](https://github.com/orhun) for creating [`git-cliff`](https://github.com/orhun/git-cliff), which this project uses to keep a changelog.
