Spaces:
Sleeping
Sleeping
File size: 616 Bytes
60470bc | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 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()
|