Skip to main content

Async Peewee

Project description

Build Status

AioPeewee

Asyncio interface for peewee modeled after torpeewee

Limitations (hopefully resolved in a couple of weeks):

  • currently just aiomysql supported

  • untested transactions

More thorough testing is on the way.

Any feedback would be greatly appreciated!

Install

pip install aiopeewee

Usage

from aiopeewee import AioModel, AioMySQLDatabase
from peewee import CharField, TextField, DateTimeField
from peewee import ForeignKeyField, PrimaryKeyField


db = AioMySQLDatabase('test', host='127.0.0.1', port=3306,
                      user='root', password='')


class User(AioModel):
    username = CharField()

    class Meta:
        database = db


class Blog(AioModel):
    user = ForeignKeyField(User)
    title = CharField(max_length=25)
    content = TextField(default='')
    pub_date = DateTimeField(null=True)
    pk = PrimaryKeyField()

    class Meta:
        database = db


# create connection pool
await db.connect(loop)

# count
await User.select().count()

# insert
user = await User.create(username='kszucs')

# modify
user.username = 'krisztian'
await user.save()

# async iteration on blog set
[b.title async for b in user.blog_set.order_by(Blog.title)]

# close connection pool
await db.close()

# see more in the tests

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

aiopeewee-0.3.0.tar.gz (11.1 kB view details)

Uploaded Source

File details

Details for the file aiopeewee-0.3.0.tar.gz.

File metadata

  • Download URL: aiopeewee-0.3.0.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for aiopeewee-0.3.0.tar.gz
Algorithm Hash digest
SHA256 5256bc6c1a51079cac3d337d4b271993484830875908edc8a8631ce20cd792d9
MD5 3c905410292d40462043e71bdc981de1
BLAKE2b-256 5c4b308f38c94457fbe97104bf95447d4b025cfdc9ca4f6b7593568f607c2ca9

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page