Spaces:
Sleeping
Sleeping
Delete database.py
Browse files- database.py +0 -24
database.py
DELETED
|
@@ -1,24 +0,0 @@
|
|
| 1 |
-
from sqlalchemy import create_engine
|
| 2 |
-
from sqlalchemy.ext.declarative import declarative_base
|
| 3 |
-
from sqlalchemy.orm import sessionmaker
|
| 4 |
-
|
| 5 |
-
SQLALCHEMY_DATABASE_URL = "sqlite:///./database/items.db"
|
| 6 |
-
|
| 7 |
-
# Create SQLite engine
|
| 8 |
-
engine = create_engine(
|
| 9 |
-
SQLALCHEMY_DATABASE_URL, connect_args={"check_same_thread": False}
|
| 10 |
-
)
|
| 11 |
-
|
| 12 |
-
# Create SessionLocal class
|
| 13 |
-
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
| 14 |
-
|
| 15 |
-
# Create Base class
|
| 16 |
-
Base = declarative_base()
|
| 17 |
-
|
| 18 |
-
# Dependency
|
| 19 |
-
def get_db():
|
| 20 |
-
db = SessionLocal()
|
| 21 |
-
try:
|
| 22 |
-
yield db
|
| 23 |
-
finally:
|
| 24 |
-
db.close()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|