Add unconnected database support
Also adds a helper for doing nested config parsing since we're getting more and more
This commit is contained in:
parent
cee708f4d8
commit
0b3b6f50fe
5 changed files with 53 additions and 12 deletions
15
src/infra/db.py
Normal file
15
src/infra/db.py
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
from sqlalchemy.orm import DeclarativeBase
|
||||
from src.config.database import Database as DatabaseConfig
|
||||
from sqlalchemy import create_engine
|
||||
|
||||
|
||||
class Base(DeclarativeBase):
|
||||
pass
|
||||
|
||||
|
||||
def get_database(config: DatabaseConfig):
|
||||
engine = create_engine(config.url, echo=config.echo)
|
||||
# Ensure that all tables exist in the database
|
||||
Base.metadata.create_all(engine)
|
||||
|
||||
return engine
|
||||
Loading…
Add table
Add a link
Reference in a new issue