Async Peewee
Project description
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
Release history Release notifications | RSS feed
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)
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5256bc6c1a51079cac3d337d4b271993484830875908edc8a8631ce20cd792d9 |
|
MD5 | 3c905410292d40462043e71bdc981de1 |
|
BLAKE2b-256 | 5c4b308f38c94457fbe97104bf95447d4b025cfdc9ca4f6b7593568f607c2ca9 |