- Notifications
You must be signed in to change notification settings - Fork7
Quart extension that provides managed connection(s) to postgresql database(s).
License
pgjones/quart-db
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Quart-DB is a Quart extension that provides managed connection(s) topostgresql or sqlite database(s).
Quart-DB is used by associating it with an app and a DB (via a URL)and then utilising theg.connection
connection,
fromquartimportg,Quart,websocketfromquart_dbimportQuartDBapp=Quart(__name__)db=QuartDB(app,url="postgresql://user:pass@localhost:5432/db_name")@app.get("/<int:id>")asyncdefget_count(id:int):result=awaitg.connection.fetch_val("SELECT COUNT(*) FROM tbl WHERE id = :id", {"id":id}, )return {"count":result}@app.post("/")asyncdefset_with_transaction():asyncwithg.connection.transaction():awaitdb.execute("UPDATE tbl SET done = :done", {"done":True}) ...return {}@app.get("/explicit")asyncdefexplicit_usage():asyncwithdb.connection()asconnection: ...
Quart-DB is developed onGitHub. If you come across an issue,or have a feature request please open anissue. If you want tocontribute a fix or the feature-implementation please do (typo fixeswelcome), by proposing amerge request.
The best way to test Quart-DB is withTox,
$pip install tox$tox
this will check the code style and run the tests.
The Quart-DBdocumentation is the best places tostart, after that try searchingstack overflow or ask for helpon gitter. If you stillcan't find an answer pleaseopen an issue.
About
Quart extension that provides managed connection(s) to postgresql database(s).