Spaces:
Sleeping
Sleeping
| import sys | |
| import os | |
| sys.path.append(os.getcwd()) | |
| from sqlalchemy import create_engine | |
| from app.db.base import settings | |
| from app.models.product import Product, Category | |
| # Use port 6543 for transaction mode (more reliable on Supabase) | |
| db_url = settings.DATABASE_URL.replace(":5432/", ":6543/") | |
| engine = create_engine(db_url) | |
| from sqlalchemy.orm import sessionmaker | |
| SessionLocal = sessionmaker(bind=engine) | |
| db = SessionLocal() | |
| try: | |
| p_count = db.query(Product).count() | |
| c_count = db.query(Category).count() | |
| print(f"Product count: {p_count}") | |
| print(f"Category count: {c_count}") | |
| finally: | |
| db.close() | |