Skip to main content

Asynchronous interface for peewee ORM powered by asyncio.

Project description


Asynchronous interface for peewee ORM powered by asyncio.

Build Status PyPi Version Documentation Status

Important notes

  • Since version 0.6.0a only peewee 3.5+ is supported
  • If you still need Python 3.4 support use older versions, i.e. pip install peewee-async==0.5.12

Version 0.6.0a is published as pre-release, mind the "a" in version identifier. That means in order to install it you should specify --pre flag for pip.


  • Requires Python 3.5+
  • 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 complete documentation:


Install with pip for PostgreSQL:

pip install --pre peewee-async; pip install aiopg

or for MySQL:

pip install --pre peewee-async; pip install aiomysql


Create 'test' PostgreSQL database for running this snippet:

createdb -E utf-8 test

The code below is using new Python 3.5 async / await syntax, but older yield from will also work!

import asyncio
import peewee
import peewee_async

# Nothing special, just define model and database:

database = peewee_async.PostgresqlDatabase(

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!



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


Copyright (c) 2014, Alexey Kinev

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

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

peewee-async-0.7.2.tar.gz (14.1 kB view hashes)

Uploaded source

Built Distribution

peewee_async-0.7.2-py3-none-any.whl (15.0 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page