Spaces:
Sleeping
Sleeping
Download counts.py from hisham-cmd/VortexCommerceBackend: direct link, hf CLI and curl.
- Browser
- Download file 616 Bytes
-
https://huggingface.co/spaces/hisham-cmd/VortexCommerceBackend/resolve/main/counts.py
- Command line
-
hf download hf://spaces/hisham-cmd/VortexCommerceBackend/counts.py
-
curl -L -o counts.py https://huggingface.co/spaces/hisham-cmd/VortexCommerceBackend/resolve/main/counts.py
616 Bytes
| 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() | |