SQLAlchemy is great but its not designed for async use cases hence it was a bit awkward to create APIs that just read/write to Sqlite. So I found Tortoise ORM, which is based around asyncio and provided multiple database drivers (sqlite, postgresql, mysql). While playing with that, I created a sample project for anyone wanting to quickly get started to cook APIs that their mobile app might want to use.
I have also created a serializer/validator around Tortoise-ORM, making things a bit more convenient. It provides unique field and required/missing fields validation for “free”. Presently it only supports foreign key relation validations (apart from non-relation validations).
Code lives here GitHub - om26er/wamp-tortoise: Using Tortoise ORM with Autobahn Python; for faster API development, the serialization semantics are somewhat inspired by Django REST Framework.
For the “curious”, here is a sample user registration example wamp-tortoise/main.py at master · om26er/wamp-tortoise · GitHub
@component.register("io.crossbar.register")
async def register_user(name: str, age: str, height: str):
serializer = ProfileSerializer()
return await serializer.create(name=name, age=age, height=height)
I don’t expect that to turn out into a full-fledged API development framework but I do plan to clean up the serialization/validation code and make the API simpler and “convenient” to use, if I find some time