2021-11-24 21:30:47 +00:00
|
|
|
|
# peewee+
|
|
|
|
|
|
|
|
|
|
Various extensions, helpers, and utilities for [Peewee](http://peewee-orm.com)
|
2021-11-25 04:30:46 +00:00
|
|
|
|
|
2022-08-05 03:52:59 +00:00
|
|
|
|
[![CI Status](https://github.com/enpaul/peewee-plus/workflows/CI/badge.svg?event=push)](https://github.com/enpaul/peewee-plus/actions)
|
2021-11-25 04:30:46 +00:00
|
|
|
|
[![PyPI Version](https://img.shields.io/pypi/v/peewee-plus)](https://pypi.org/project/peewee-plus/)
|
2022-09-07 19:41:02 +00:00
|
|
|
|
[![PyPI Downloads](https://img.shields.io/pypi/dm/peewee-plus)](https://libraries.io/pypi/peewee-plus)
|
2021-11-25 04:30:46 +00:00
|
|
|
|
[![License](https://img.shields.io/pypi/l/peewee-plus)](https://opensource.org/licenses/MIT)
|
|
|
|
|
[![Python Supported Versions](https://img.shields.io/pypi/pyversions/peewee-plus)](https://www.python.org)
|
|
|
|
|
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
|
|
|
|
|
|
|
|
|
|
See the [Changelog](https://github.com/enpaul/peewee-plus/blob/devel/CHANGELOG.md) for
|
|
|
|
|
release history.
|
|
|
|
|
|
|
|
|
|
## Documentation
|
|
|
|
|
|
2023-05-04 18:55:56 +00:00
|
|
|
|
*The documentation for this project is currently a work in progress. Please see the source
|
|
|
|
|
code for complete docs*
|
2021-11-25 04:30:46 +00:00
|
|
|
|
|
|
|
|
|
- [Installing](#installing)
|
|
|
|
|
- [Features](#features)
|
|
|
|
|
- [For Developers](#for-developers)
|
|
|
|
|
|
|
|
|
|
## Installing
|
|
|
|
|
|
2023-04-13 17:34:37 +00:00
|
|
|
|
peewee+ is [available on PyPI](https://pypi.org/project/peewee-plus/) and can be installed
|
2021-11-25 04:30:46 +00:00
|
|
|
|
using Poetry, Pipenv, or Pip:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
# Using poetry
|
|
|
|
|
poetry add peewee-plus
|
|
|
|
|
|
|
|
|
|
# Using pipenv
|
|
|
|
|
pipenv install peewee-plus
|
|
|
|
|
|
|
|
|
|
# Using pip
|
|
|
|
|
python -m venv peewee
|
|
|
|
|
source peewee/bin/activate
|
|
|
|
|
python -m pip install peewee-plus
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Once installed, Peewee+ can be imported like below:
|
|
|
|
|
|
|
|
|
|
```python
|
|
|
|
|
import peewee_plus
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Features
|
|
|
|
|
|
|
|
|
|
### Constants
|
|
|
|
|
|
|
|
|
|
`SQLITE_DEFAULT_PRAGMAS` - The default pragmas to use with an SQLite database connection,
|
|
|
|
|
taken directly from the
|
|
|
|
|
[Peewee docs](http://docs.peewee-orm.com/en/latest/peewee/database.html#recommended-settings).
|
|
|
|
|
|
|
|
|
|
`SQLITE_DEFAULT_VARIABLE_LIMIT` - The maximum number of variables an SQL query can use
|
|
|
|
|
when using SQLite
|
|
|
|
|
|
|
|
|
|
### Functions
|
|
|
|
|
|
2023-05-04 18:55:56 +00:00
|
|
|
|
`calc_batch_size` - Helper function for writing backend-agnostic batch queries while
|
|
|
|
|
accounting for the
|
2023-04-13 17:34:37 +00:00
|
|
|
|
[SQLite max variable limit](https://www.sqlite.org/limits.html#max_variable_number).
|
2021-11-25 04:30:46 +00:00
|
|
|
|
|
2023-05-04 18:55:56 +00:00
|
|
|
|
`flat_transaction` - Decorator function for wrapping callables in a database transaction
|
|
|
|
|
without creating nested transactions
|
2022-01-20 06:05:25 +00:00
|
|
|
|
|
2021-11-25 04:30:46 +00:00
|
|
|
|
### Classes
|
|
|
|
|
|
2023-05-04 18:55:56 +00:00
|
|
|
|
`PathField` - A Peewee database field for storing
|
2021-11-25 04:30:46 +00:00
|
|
|
|
[Pathlib](https://docs.python.org/3/library/pathlib.html) objects, optionally relative to
|
|
|
|
|
a runtime value.
|
|
|
|
|
|
2023-05-04 18:55:56 +00:00
|
|
|
|
`PrecisionFloatField` - A Peewee database field for storing floats while specifying the
|
2021-11-25 04:30:46 +00:00
|
|
|
|
[MySQL precision parameters](https://dev.mysql.com/doc/refman/8.0/en/floating-point-types.html)
|
|
|
|
|
`M` and `D`
|
|
|
|
|
|
2023-05-04 18:55:56 +00:00
|
|
|
|
`JSONField` - A Peewee database field for storing arbitrary JSON-serializable data
|
2021-11-25 04:30:46 +00:00
|
|
|
|
|
2023-05-04 18:55:56 +00:00
|
|
|
|
`EnumField` - A Peewee database field for storing Enums by name
|
2021-11-25 04:30:46 +00:00
|
|
|
|
|
2023-05-04 18:58:02 +00:00
|
|
|
|
`TimedeltaField` A Peewee database field for natively storing
|
|
|
|
|
[`datetime.timedelta`](https://docs.python.org/3/library/datetime.html#datetime.timedelta)
|
|
|
|
|
objects
|
|
|
|
|
|
2021-11-25 04:30:46 +00:00
|
|
|
|
## For Developers
|
|
|
|
|
|
|
|
|
|
All project contributors and participants are expected to adhere to the
|
2023-05-04 18:55:56 +00:00
|
|
|
|
[Contributor Covenant Code of Conduct, v2](CODE_OF_CONDUCT.md)
|
|
|
|
|
([external link](https://www.contributor-covenant.org/version/2/0/code_of_conduct/)).
|
2021-11-25 04:30:46 +00:00
|
|
|
|
|
|
|
|
|
The `devel` branch has the latest (and potentially unstable) changes. The stable releases
|
|
|
|
|
are tracked on [Github](https://github.com/enpaul/peewee-plus/releases),
|
|
|
|
|
[PyPi](https://pypi.org/project/peewee-plus/#history), and in the
|
|
|
|
|
[Changelog](CHANGELOG.md).
|
|
|
|
|
|
|
|
|
|
- To report a bug, request a feature, or ask for assistance, please
|
|
|
|
|
[open an issue on the Github repository](https://github.com/enpaul/peewee-plus/issues/new).
|
|
|
|
|
- To report a security concern or code of conduct violation, please contact the project
|
|
|
|
|
author directly at **me \[at\] enp dot one**.
|
|
|
|
|
- To submit an update, please
|
|
|
|
|
[fork the repository](https://docs.github.com/en/enterprise/2.20/user/github/getting-started-with-github/fork-a-repo)
|
|
|
|
|
and [open a pull request](https://github.com/enpaul/peewee-plus/compare).
|
|
|
|
|
|
2023-04-13 17:36:54 +00:00
|
|
|
|
Developing this project requires [Python 3.10](https://www.python.org/downloads/) or later
|
|
|
|
|
and [Poetry 1.2](https://python-poetry.org/docs/#installation) or later. GNU Make can
|
2021-11-25 04:30:46 +00:00
|
|
|
|
optionally be used to quickly setup a local development environment, but this is not
|
|
|
|
|
required.
|
|
|
|
|
|
|
|
|
|
To setup a local development environment:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
# Clone the repository...
|
|
|
|
|
# ...over HTTPS
|
|
|
|
|
git clone https://github.com/enpaul/peewee-plus.git
|
|
|
|
|
# ...over SSH
|
|
|
|
|
git clone git@github.com:enpaul/peewee-plus.git
|
|
|
|
|
|
|
|
|
|
cd peewee-plus/
|
|
|
|
|
|
|
|
|
|
# Create and configure the local dev environment
|
|
|
|
|
make dev
|
|
|
|
|
|
|
|
|
|
# See additional make targets
|
|
|
|
|
make help
|
|
|
|
|
```
|