APA-URAAS / scratch /inspect_citations.py
Lordkiki's picture
Deploy URAAS — African Research Archival & Analytics System
74bf532 verified
Raw
History Blame Contribute Delete
762 Bytes
import os
import sys
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from sqlalchemy import text
from uraas.database import Base, SessionLocal, engine
def inspect():
session = SessionLocal()
try:
# Check if tables exist first
tables = ["citations", "citation_metrics", "author_metrics"]
for table in tables:
try:
res = session.execute(text(f"SELECT COUNT(*) FROM {table}")).scalar()
print(f"Table '{table}' has {res} rows")
except Exception as e:
print(f"Table '{table}' error: {e}")
except Exception as e:
print(f"Error: {e}")
finally:
session.close()
if __name__ == "__main__":
inspect()