aioorm
version: 0.1.6
status: production
author: hsz
email: hsz1273327@gmail.com
Asyncio interface for peewee modeled after torpeewee
Feature
support mysql and postgresql
database factory using database URL
use peewee’s fields
ManyToManyField support
Shortcuts support
csv dump /load support
can use playhose.postgres_ext.JSONField
Install
python -m pip install aioorm
Example: GRUD
from aioorm 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()
# async iteration on select query
async for user in User.select():
print(user)
# fetch all records as a list from a query in one pass
users = await User.select()
# 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
Example: Many to many
Note that AioManyToManyField must be used instead of ManyToMany.
from aioorm import AioManyToManyField
class User(AioModel):
username = CharField(unique=True)
class Meta:
database = db
class Note(AioModel):
text = TextField()
users = AioManyToManyField(User)
class Meta:
database = db
NoteUserThrough = Note.users.get_through_model()
async for user in note.users:
# do something with the users
Currently the only limitation I’m aware of immidiate setting of instance relation must be replaced with a method call:
# original, which is not supported
charlie.notes = [n2, n3]
# use instead
await charlie.notes.set([n2, n3])
Serializing
Converting to dict requires the asyncified version of model_to_dict
from aioorm import model_to_dict
serialized = await model_to_dict(user)
Dump to csv
tables can be dump to a csv file.
from aioorm.utils import aiodump_csv
query = User.select().order_by(User_csv.id)
await aiodump_csv(query,str(filepath))
Documentation
TODO
async dataset support
more test
Limitations
untested transactions
only support mysql and postgresql
Bug fix
fixed get and get_or_create ‘s bug
Metadata
Release files for aioorm 0.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| aioorm-0.1.6.tar.gz | 31.9 kB | Without provenance | Details for aioorm-0.1.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| aioorm-0.1.6-py3-none-any.whl | Python 3 | none | any | Details for aioorm-0.1.6-py3-none-any.whl |
Total release size: 59.3 kB
Release files / aioorm-0.1.6.tar.gz
| Download URL | aioorm-0.1.6.tar.gz |
|---|---|
| Size | 31.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fc6b105e422e5549b7591d78cd883baaeeb0532a0844433b73bce22511a76bf1
|
|
BLAKE2b-256 checksum How to use checksums |
9f17ddfdc49f637bf79b76e4691109fc3443ebf5f7521892059ac0ac8de84f1b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Python-urllib/3.6
|
Release files / aioorm-0.1.6-py3-none-any.whl
| Download URL | aioorm-0.1.6-py3-none-any.whl |
|---|---|
| Size | 27.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ce93894caf6f63913f868a5b5a4b5f47c9ce5efc2c12d713851b2572da634522
|
|
BLAKE2b-256 checksum How to use checksums |
1727cca3916a9af9c00fb37d03953368bd84dfa3bf3c7e02b8b4597c91479588
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Python-urllib/3.6
|
Security for aioorm 0.1.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.