fix: Add missing get_db function to database.py
The main.py was trying to import get_db for blockchain initialization but it was missing from database.py. Added the get_db generator function that creates and properly closes database sessions.
This commit is contained in:
parent
238b79268d
commit
1fd71e71e1
@ -23,3 +23,12 @@ def init_db():
|
||||
"""Initialiser la base de données (créer les tables)"""
|
||||
from .models import Base
|
||||
Base.metadata.create_all(bind=engine)
|
||||
|
||||
|
||||
def get_db():
|
||||
"""Dépendance pour obtenir une session de base de données"""
|
||||
db = SessionLocal()
|
||||
try:
|
||||
yield db
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user