peewee-async is a library providing asynchronous interface powered by asyncio for peewee ORM.

Current state: alpha, yet API seems fine and mostly stable.

In current version (0.5.x) new-high level API is introduced while older low-level API partially marked as deprecated.

  • Works on Python 3.4+
  • Has support for PostgreSQL via aiopg
  • Has support for MySQL via aiomysql
  • Single point for high-level async API
  • Drop-in replacement for sync code, sync will remain sync
  • Basic operations are supported
  • Transactions support is present, yet not heavily tested

The source code is hosted on GitHub.


import asyncio
import peewee
import peewee_async

# Nothing special, just define model and database:

database = peewee_async.PostgresqlDatabase('test')

class TestModel(peewee.Model):
    text = peewee.CharField()

    class Meta:
        database = database

# Look, sync code is working!

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

# Create async models manager:

objects = peewee_async.Manager(database)

# No need for sync anymore!


async def handler():
    await objects.create(TestModel, text="Not bad. Watch this, I'm async!")
    all_objects = await objects.execute(
    for obj in all_objects:

loop = asyncio.get_event_loop()

# Clean up, can do it sync again:
with objects.allow_sync():

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


Install latest version from PyPI.

For PostgreSQL:

pip install peewee-async aiopg

For MySQL:

pip install peewee-async aiomysql

Install from sources

git clone
cd peewee-async
python install

Running tests

Prepare environment for tests:

  • Clone source code from GitHub as shown above
  • Create PostgreSQL database for testing, i.e. named ‘test’
  • Create tests.json config file based on tests.json.sample

Then run tests:

python test

Report bugs and discuss

You are welcome to add discussion topics or bug reports to tracker on GitHub!

Indices and tables