You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In some frameworks, such as Django, views are wrapped with transaction handling logic. If an exception is raised, then the transaction is rolled back.
To use transactions is more explicit currently in Piccolo - a context manager has to be used within the view itself.
@app.get("/")asyncdefmy_endpoint():
try:
asyncwithMyTable._meta.db.transaction():
# a bunch of queriesexceptException:
returnJSONResponse({"message": "something went wrong"})
returnJSONResponse({"message": "success"})
It would be nice to have a decorator which wraps a view with this logic:
Based on this discussion:
piccolo-orm/piccolo#185
In some frameworks, such as Django, views are wrapped with transaction handling logic. If an exception is raised, then the transaction is rolled back.
To use transactions is more explicit currently in Piccolo - a context manager has to be used within the view itself.
It would be nice to have a decorator which wraps a view with this logic:
The text was updated successfully, but these errors were encountered: