Metadata-Version: 2.3
Name: sqlean-driver
Version: 0.2.0
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: MIT License
        
        Copyright (c) 2023-present Edgar Ramírez Mondragón <edgarrm358@gmail.com>
        
        Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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 :: 3.13
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<3.47,>=0.21.5.1; python_version < '3.9'
Requires-Dist: sqlean-py>=0.21.5.1; python_version >= '3.9'
Provides-Extra: coverage
Requires-Dist: coverage[toml]>=7.4.2; extra == 'coverage'
Provides-Extra: testing
Requires-Dist: coverage[toml]>=7.4.2; extra == 'testing'
Requires-Dist: pytest; extra == 'testing'
Requires-Dist: pytest-github-actions-annotate-failures; extra == 'testing'
Provides-Extra: typing
Requires-Dist: mypy>=1; extra == 'typing'
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.
