Integration between the Quart web framework and the Peewee ORM through the Peewee-AIO
Project description
Quart-Peewee
Integration between the Quart web framework and the Peewee ORM through the Peewee-AIO
Usage
from peewee_aio.fields import CharField
from quart import Quart, request
from quart_peewee import QuartPeewee
app = Quart(__name__)
db = QuartPeewee("aiosqlite:///app.db")
db.init_app(app)
class User(db.Model):
name = CharField(unique=True)
@app.before_serving
async def before_serving():
await db.create_tables()
@app.route("/create_user", methods=["POST"])
async def create_user():
data = await request.get_json(force=True)
await User.create(name=data["name"])
return ""
@app.route("/get_users", methods=["GET"])
async def get_users():
return await User.select().dicts()
@app.route("/delete_user", methods=["DELETE"])
async def delete_user():
data = await request.get_json(force=True)
await User.delete().where(User.name == data["name"])
return ""
if __name__ == "__main__":
app.run()
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
quart_peewee-0.1.0.tar.gz
(2.4 kB
view hashes)
Built Distribution
Close
Hashes for quart_peewee-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1de751d2fe03f515051564ff6d1ae5539cd1b08698b79deb594535588f2ac056 |
|
MD5 | b5d6a09c01f34200ad6e90fcb5fbb504 |
|
BLAKE2b-256 | fa9d5176917513529a98ec59d215ead2c707fd40f952f9d22de236b24952fbd6 |