Initial commit
This commit is contained in:
0
app/db/__init__.py
Normal file
0
app/db/__init__.py
Normal file
BIN
app/db/__pycache__/__init__.cpython-312.pyc
Normal file
BIN
app/db/__pycache__/__init__.cpython-312.pyc
Normal file
Binary file not shown.
BIN
app/db/__pycache__/base.cpython-312.pyc
Normal file
BIN
app/db/__pycache__/base.cpython-312.pyc
Normal file
Binary file not shown.
BIN
app/db/__pycache__/session.cpython-312.pyc
Normal file
BIN
app/db/__pycache__/session.cpython-312.pyc
Normal file
Binary file not shown.
5
app/db/base.py
Normal file
5
app/db/base.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from sqlalchemy.orm import DeclarativeBase
|
||||
|
||||
|
||||
class Base(DeclarativeBase):
|
||||
pass
|
||||
13
app/db/session.py
Normal file
13
app/db/session.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
from app.core.config import settings
|
||||
|
||||
engine = create_engine(settings.DATABASE_URL)
|
||||
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
||||
|
||||
def get_db():
|
||||
db = SessionLocal()
|
||||
try:
|
||||
yield db
|
||||
finally:
|
||||
db.close()
|
||||
Reference in New Issue
Block a user