-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add piccolo db #104
Add piccolo db #104
Conversation
d9bda0b
to
1e0d16e
Compare
Also use FastAPI dependency for async db transaction.
1e0d16e
to
a88cb39
Compare
apphelpers/db/piccolo.py
Outdated
def dbtransaction(engine: Optional[PostgresEngine] = None, allow_nested=True): | ||
def wrapper(f): | ||
@wraps(f) | ||
async def f_wrapped(*args, **kw): | ||
async with dbtransaction_ctx(engine, allow_nested=allow_nested): | ||
return await f(*args, **kw) | ||
|
||
return f_wrapped | ||
|
||
return wrapper |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We won't be using it in FastAPI. This is only for hug compatibility (and apphelpers tests).
result = f(*args, **kw) | ||
return result | ||
with dbtransaction_ctx(db): | ||
return f(*args, **kw) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We won't be using it in FastAPI. This is only for hug compatibility (and apphelpers tests).
Also use FastAPI dependency for async db transaction.