Skip to main content

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

Installation

pip install quart-peewee

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


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.1.tar.gz (2.4 kB view details)

Uploaded Source

Built Distribution

quart_peewee-0.1.1-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

Details for the file quart_peewee-0.1.1.tar.gz.

File metadata

  • Download URL: quart_peewee-0.1.1.tar.gz
  • Upload date:
  • Size: 2.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for quart_peewee-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b7e640d59c814cb63831eaa87620a98b13f229cdb87e1b29d475a0344625ef08
MD5 909e78a337c8a1d76b1a2b5fb2bebfef
BLAKE2b-256 9509ffc65d6ccec017294ef21218aefad551ab48fe5f3fec27a28fe645d1f9b3

See more details on using hashes here.

File details

Details for the file quart_peewee-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for quart_peewee-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6265a7347fe7bba19c93bd7be2438250e9b0925cded6f486c1257258ab827573
MD5 0b82a88bd2248881cfddf2f7e66dff27
BLAKE2b-256 fa18bb8605da88a2a99f3d7113d1e89641fd9fd39cf7cc8e3d4b1e7b27617bc0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page