mirror of
https://github.com/wowlikon/LibraryAPI.git
synced 2025-12-11 21:30:46 +00:00
changed project structure and splited models and routes files
This commit is contained in:
14
src/app/database.py
Normal file
14
src/app/database.py
Normal file
@@ -0,0 +1,14 @@
|
||||
from sqlmodel import create_engine, SQLModel, Session
|
||||
from decouple import config
|
||||
|
||||
# Get database configuration
|
||||
DATABASE_URL = config('DATABASE_URL', cast=str, default='sqlite:///./bookapi.db')
|
||||
|
||||
# Create database engine
|
||||
engine = create_engine(str(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