Spaces:
Sleeping
Sleeping
Delete tmp_check_db.py with huggingface_hub
Browse files- tmp_check_db.py +0 -38
tmp_check_db.py
DELETED
|
@@ -1,38 +0,0 @@
|
|
| 1 |
-
|
| 2 |
-
import os
|
| 3 |
-
import sys
|
| 4 |
-
|
| 5 |
-
# Add current directory to path so we can import 'app'
|
| 6 |
-
sys.path.append(os.getcwd())
|
| 7 |
-
|
| 8 |
-
from app.core.config import settings
|
| 9 |
-
from app.db.base import SessionLocal
|
| 10 |
-
from app.models.product import Product, Category
|
| 11 |
-
|
| 12 |
-
def check_db():
|
| 13 |
-
print(f"DB URL: {settings.DATABASE_URL}")
|
| 14 |
-
db_path = settings.DATABASE_URL.replace("sqlite:///", "")
|
| 15 |
-
print(f"DB PATH: {db_path}")
|
| 16 |
-
print(f"DB EXISTS: {os.path.exists(db_path)}")
|
| 17 |
-
|
| 18 |
-
if os.path.exists(db_path):
|
| 19 |
-
db = SessionLocal()
|
| 20 |
-
try:
|
| 21 |
-
product_count = db.query(Product).count()
|
| 22 |
-
active_product_count = db.query(Product).filter(Product.is_active == True, Product.deleted_at == None).count()
|
| 23 |
-
category_count = db.query(Category).count()
|
| 24 |
-
|
| 25 |
-
print(f"Total Products: {product_count}")
|
| 26 |
-
print(f"Active Products: {active_product_count}")
|
| 27 |
-
print(f"Total Categories: {category_count}")
|
| 28 |
-
|
| 29 |
-
categories = db.query(Category).all()
|
| 30 |
-
print("\nCategories:")
|
| 31 |
-
for cat in categories:
|
| 32 |
-
print(f"- ID: {cat.id}, Name: {cat.name_en}, Parent: {cat.parent_id}")
|
| 33 |
-
|
| 34 |
-
finally:
|
| 35 |
-
db.close()
|
| 36 |
-
|
| 37 |
-
if __name__ == "__main__":
|
| 38 |
-
check_db()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|