Replies: 1 comment
-
|
@Faridalim The best thing to try is To setup a connection pool, you have something like this in your app file: app = FastAPI()
@app.on_event("startup")
async def open_database_connection_pool():
try:
engine = engine_finder()
await engine.start_connection_pool()
except Exception:
print("Unable to connect to the database")
@app.on_event("shutdown")
async def close_database_connection_pool():
try:
engine = engine_finder()
await engine.close_connection_pool()
except Exception:
print("Unable to connect to the database")You shouldn't have to pass the sessions around with Piccolo. It does have transaction support though if you need it. Does that help? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, thanks for sharing this ORM. It looks simple and easy which is a good thing.
Could anybody give me an example of using Piccolo in Fastapi especially when using database local session. I mean, how to use Piccolo if i have many files in Fastapi that need db connections? How to use it with connection pool? Thank you very much
Beta Was this translation helpful? Give feedback.
All reactions