Skip to main content

a simple sanic middleware for aioorm

Project description


version: 0.0.5

author: hsz


* simple to use, just like using flask's extension
* design to take the place of sanic-peewee

.. code:: python

from sanic_aioorm import AioOrm, AioModel
from peewee import Proxy, CharField
db = Proxy()

class User(AioModel):
username = CharField()
class Meta:
database = db

.. code:: python

from sanic import Sanic
from sanic.response import json
from sanic_aioorm import AioOrm
from ex_model import User, db
app = Sanic()
AioOrm.SetConfig(app, defaultdb="mysql://root:hsz881224@localhost:3306/test")
orm = AioOrm(app)
orm.create_tables(User=[{'username': "hsz"}, {'username': "jojo"}])

async def testget(request):
users = await
except Exception as e:
return json({"error": str(e)})
return json({"hello": [await u.to_dict() for u in users]})"/")
async def testpost(request):
users = await User.create(request.json)
except Exception as e:
return json({"error": str(e)})
return json({"hello": [u.to_dict() for u in users]})

if __name__ == "__main__":"", port=4500)


- ``python -m pip install sanic-aioorm``

* only support mysql and pgsql

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for sanic-aioorm, version 0.0.5
Filename, size File type Python version Upload date Hashes
Filename, size sanic_aioorm-0.0.5-py3-none-any.whl (6.5 kB) File type Wheel Python version 3.6 Upload date Hashes View
Filename, size sanic-aioorm-0.0.5.tar.gz (5.1 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page