mirror of
https://github.com/wowlikon/LibraryAPI.git
synced 2025-12-11 21:30:46 +00:00
some comments and fixes
This commit is contained in:
@@ -2,15 +2,17 @@ from sqlmodel import create_engine, SQLModel, Session
|
||||
from dotenv import load_dotenv
|
||||
import os
|
||||
|
||||
# Get database configuration
|
||||
load_dotenv()
|
||||
|
||||
DATABASE_URL = os.getenv("DATABASE_URL")
|
||||
if not DATABASE_URL:
|
||||
raise ValueError("DATABASE_URL environment variable is not set")
|
||||
|
||||
# Create database engine
|
||||
engine = create_engine(DATABASE_URL, echo=True)
|
||||
SQLModel.metadata.create_all(engine)
|
||||
|
||||
# Get database session
|
||||
def get_session():
|
||||
with Session(engine) as session:
|
||||
yield session
|
||||
|
||||
Reference in New Issue
Block a user