Metadata-Version: 2.3
Name: peewee-async
Version: 2.0.0
Summary: Asynchronous interface for peewee ORM powered by asyncio.
Author: Alexey Kinev, Gorshkov Nikolay
Author-email: Alexey Kinev <rudy@05bit.com>, Gorshkov Nikolay <nogamemorebrain@gmail.com>
Requires-Dist: peewee>=4,<5
Requires-Dist: typing-extensions>=4.12.2
Requires-Dist: pytest==9.0.3 ; extra == 'dev'
Requires-Dist: pytest-asyncio==1.3.0 ; extra == 'dev'
Requires-Dist: pytest-mock>=3.14.0 ; extra == 'dev'
Requires-Dist: peewee-async[postgresql] ; extra == 'dev'
Requires-Dist: peewee-async[mysql] ; extra == 'dev'
Requires-Dist: peewee-async[psycopg] ; extra == 'dev'
Requires-Dist: peewee-async[sqlite] ; extra == 'dev'
Requires-Dist: mypy>=1.19.0 ; extra == 'dev'
Requires-Dist: ruff==0.15.10 ; extra == 'dev'
Requires-Dist: types-pymysql>=1.1.0 ; extra == 'dev'
Requires-Dist: poethepoet==0.44.0 ; extra == 'dev'
Requires-Dist: commitizen>=4.13.8,<5 ; extra == 'dev'
Requires-Dist: sphinx>=8.1.3 ; extra == 'docs'
Requires-Dist: sphinx-rtd-theme>=3.1.0 ; extra == 'docs'
Requires-Dist: aiomysql>=0.3.2 ; extra == 'mysql'
Requires-Dist: cryptography>=46.0.5 ; extra == 'mysql'
Requires-Dist: aiopg>=1.4.0 ; extra == 'postgresql'
Requires-Dist: psycopg[binary,pool]>=3.3.0 ; extra == 'psycopg'
Requires-Dist: aiosqlite>=0.22.1 ; extra == 'sqlite'
Requires-Python: >=3.10
Provides-Extra: dev
Provides-Extra: docs
Provides-Extra: mysql
Provides-Extra: postgresql
Provides-Extra: psycopg
Provides-Extra: sqlite
Description-Content-Type: text/markdown

peewee-async
============

Asynchronous interface for **[peewee](https://github.com/coleifer/peewee)**
ORM powered by **[asyncio](https://docs.python.org/3/library/asyncio.html)**.

[![CI workflow](https://github.com/05bit/peewee-async/actions/workflows/tests.yml/badge.svg)](https://github.com/05bit/peewee-async/actions/workflows/tests.yml) [![PyPi Version](https://img.shields.io/pypi/v/peewee-async.svg)](https://pypi.python.org/pypi/peewee-async)
 [![Documentation Status](https://readthedocs.org/projects/peewee-async-lib/badge/?version=latest)](https://peewee-async-lib.readthedocs.io/en/latest/?badge=latest)


Overview
--------

* Requires Python 3.10+
* Has support for PostgreSQL via [aiopg](https://github.com/aio-libs/aiopg) and [psycopg3](https://github.com/psycopg/psycopg)
* Has support for MySQL via [aiomysql](https://github.com/aio-libs/aiomysql)
* Has support for Sqlite via [aiosqlite](https://github.com/omnilib/aiosqlite)
* Asynchronous analogues of peewee sync methods with prefix aio_
* Drop-in replacement for sync code, sync will remain sync
* Most basic operations are supported
* Transactions support is present

The complete documentation:  
http://peewee-async-lib.readthedocs.io


Install
-------

Install with `pip` for PostgreSQL aiopg backend:

```bash
pip install peewee-async[postgresql]
```

or for PostgreSQL psycopg3 backend:

```bash
pip install peewee-async[psycopg]
```

or for MySQL:

```bash
pip install peewee-async[mysql]
```

or for Sqlite:

```bash
pip install peewee-async[sqlite]
```

Quickstart
----------

Create 'test' PostgreSQL database for running this snippet:

    createdb -E utf-8 test

```python
import asyncio
import peewee
import peewee_async

# Nothing special, just define model and database:

database = peewee_async.PooledPostgresqlDatabase(
    database='db_name',
    user='user',
    host='127.0.0.1',
    port='5432',
    password='password',
)

class TestModel(peewee_async.AioModel):
    text = peewee.CharField()

    class Meta:
        database = database

# Look, sync code is working!

TestModel.create_table(True)
TestModel.create(text="Yo, I can do it sync!")
database.close()

# No need for sync anymore!

database.set_allow_sync(False)

async def handler():
    await TestModel.aio_create(text="Not bad. Watch this, I'm async!")
    all_objects = await TestModel.select().aio_execute()
    for obj in all_objects:
        print(obj.text)

loop = asyncio.get_event_loop()
loop.run_until_complete(handler())
loop.close()

# Clean up, can do it sync again:
with database.allow_sync():
    TestModel.drop_table(True)

# Expected output:
# Yo, I can do it sync!
# Not bad. Watch this, I'm async!
```


More examples
-------------

Check the .`/examples` directory for more.


Documentation
-------------

http://peewee-async-lib.readthedocs.io

http://peewee-async.readthedocs.io - **DEPRECATED**


Developing
----------

Install dependencies using pip:

```bash
pip install -e .[dev]
```

Run databases:

```bash
docker-compose up -d
```

Run tests:

```bash
pytest tests -v -s
```


Discuss
-------

You are welcome to add discussion topics or bug reports to tracker on GitHub: https://github.com/05bit/peewee-async/issues

License
-------

Copyright (c) 2014, Alexey Kinev <rudy@05bit.com>

Licensed under The MIT License (MIT),
see LICENSE file for more details.
