Skip to main content

peewee-async

Asynchronous interface for peewee ORM powered by asyncio.

CI workflow PyPi Version Documentation Status

Overview

  • Requires Python 3.10+
  • Has support for PostgreSQL via aiopg and psycopg3
  • Has support for MySQL via aiomysql
  • Has support for Sqlite via 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:

pip install peewee-async[postgresql]

or for PostgreSQL psycopg3 backend:

pip install peewee-async[psycopg]

or for MySQL:

pip install peewee-async[mysql]

or for Sqlite:

pip install peewee-async[sqlite]

Quickstart

Create 'test' PostgreSQL database for running this snippet:

createdb -E utf-8 test
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:

pip install -e .[dev]

Run databases:

docker-compose up -d

Run tests:

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.

Metadata

Release files for peewee-async 2.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for peewee-async 2.1.0
File Size Uploaded
peewee_async-2.1.0.tar.gz 15.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for peewee-async 2.1.0
File Interpreter ABI Platform
peewee_async-2.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 34.4 kB

Release files / peewee_async-2.1.0.tar.gz

Download URL peewee_async-2.1.0.tar.gz
Size 15.4 kB
Tags Source
SHA-256 checksum
How to use checksums
2c1d58269cb17e4cd5de78561f6b01152ca3fb8987241a4408407b64d7757d9f
BLAKE2b-256 checksum
How to use checksums
0f196e681114e77d45c2afb86348f59fe9917a16c802d0a61b72682168172db2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.2 {"installer":{"name":"uv","version":"0.12.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / peewee_async-2.1.0-py3-none-any.whl

Download URL peewee_async-2.1.0-py3-none-any.whl
Size 18.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5424beef9065782b3208869daeb97f9192d0c43ce9b8be14dafcb5e49b39c991
BLAKE2b-256 checksum
How to use checksums
b8d0cd83c07e37ff59df50d94153a6d5c6e2577f35ae24a64e59e4690882bcc4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.2 {"installer":{"name":"uv","version":"0.12.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

2.1.0 This release

2 release files

2.0.0

2 release files

1.3.0

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.12.2

2 release files

0.12.0

2 release files

0.10.0

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.5.11

2 release files

0.5.10

2 release files

0.5.9

2 release files

0.5.8

2 release files

0.5.7

2 release files

0.5.6

2 release files

0.5.5

2 release files

0.5.4

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5

2 release files

0.4.1

1 release file

0.4.0

1 release file

0.3.4

1 release file

0.3.3

1 release file

0.3.2

1 release file

0.3.1

1 release file

0.3

1 release file

0.2

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page