Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/edgarrmondragon/sqlalchemy-sqlean
SQLAlchemy driver for the sqlean.py SQLite wrapper
https://github.com/edgarrmondragon/sqlalchemy-sqlean
python-sqlite3 sqlalchemy sqlalchemy-dialects sqlite3 stats
Last synced: 3 months ago
JSON representation
SQLAlchemy driver for the sqlean.py SQLite wrapper
- Host: GitHub
- URL: https://github.com/edgarrmondragon/sqlalchemy-sqlean
- Owner: edgarrmondragon
- License: mit
- Created: 2023-06-26T16:30:57.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-09-16T19:54:19.000Z (4 months ago)
- Last Synced: 2024-09-17T01:12:13.981Z (4 months ago)
- Topics: python-sqlite3, sqlalchemy, sqlalchemy-dialects, sqlite3, stats
- Language: Python
- Homepage: https://pypi.org/p/sqlean-driver
- Size: 139 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# 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, selectengine = 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, selectsqlean.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.