First Check
Commit to Help
Example Code
Architecture question, no code needed.
Description
I need the "engine" instance in my services and routers to create "session" to access the database?
define this somewhere
engine = create_engine(sqlite_url, echo=False)
use this everywhere
session = Session(engine)
All samples are single file examples so no imports of engine.
It is unclear to me if SQLModel has a solution or should I create my own singleton to hold the engine instance.
My Flask background had me put the engine from SqlAlchemy to the app instance, is this prefred in FastApi (But not sure if I can import the app instance from main.py).
Operating System
Windows
Operating System Details
No response
SQLModel Version
0.0.4
Python Version
3.9.7
Additional Context
No response
First Check
Commit to Help
Example Code
Description
I need the "engine" instance in my services and routers to create "session" to access the database?
define this somewhere
use this everywhere
session = Session(engine)
All samples are single file examples so no imports of engine.
It is unclear to me if SQLModel has a solution or should I create my own singleton to hold the engine instance.
My Flask background had me put the engine from SqlAlchemy to the app instance, is this prefred in FastApi (But not sure if I can import the app instance from main.py).
Operating System
Windows
Operating System Details
No response
SQLModel Version
0.0.4
Python Version
3.9.7
Additional Context
No response