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.

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-2.1.0.tar.gz (15.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

peewee_async-2.1.0-py3-none-any.whl (18.9 kB view details)

Uploaded Python 3

File details

Details for the file peewee_async-2.1.0.tar.gz.

File metadata

  • Download URL: peewee_async-2.1.0.tar.gz
  • Upload date:
  • Size: 15.4 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for peewee_async-2.1.0.tar.gz
Algorithm Hash digest
SHA256 2c1d58269cb17e4cd5de78561f6b01152ca3fb8987241a4408407b64d7757d9f
MD5 dfe7912d9c838c226fb0835db7cda735
BLAKE2b-256 0f196e681114e77d45c2afb86348f59fe9917a16c802d0a61b72682168172db2

See more details on using hashes here.

File details

Details for the file peewee_async-2.1.0-py3-none-any.whl.

File metadata

  • Download URL: peewee_async-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.9 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for peewee_async-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5424beef9065782b3208869daeb97f9192d0c43ce9b8be14dafcb5e49b39c991
MD5 96877752eaa7928762627538c278bd06
BLAKE2b-256 b8d0cd83c07e37ff59df50d94153a6d5c6e2577f35ae24a64e59e4690882bcc4

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

2.1.0 This release

2 files

2.0.0

2 files

1.3.0

2 files

1.2.1

2 files

1.2.0

2 files

1.1.0

2 files

1.0.0

2 files

0.12.2

2 files

0.12.1

2 files

0.12.0

2 files

0.10.0

2 files

0.9.1

2 files

0.9.0

2 files

0.8.1

2 files

0.8.0

2 files

0.7.2

2 files

0.7.1

2 files

0.7.0

2 files

0.5.12

2 files

0.5.11

2 files

0.5.10

2 files

0.5.9

2 files

0.5.8

2 files

0.5.7

2 files

0.5.6

2 files

0.5.5

2 files

0.5.4

2 files

0.5.3

2 files

0.5.2

2 files

0.5.1

2 files

0.5

2 files

0.4.1

1 file

0.4.0

1 file

0.3.4

1 file

0.3.3

1 file

0.3.2

1 file

0.3.1

1 file

0.3

1 file

0.2

1 file

0.1

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page