File size: 838 Bytes
92cf271
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import asyncio
import os
from dotenv import load_dotenv
import asyncpg

load_dotenv()

async def check():
    url = os.environ['DATABASE_URL'].replace('postgresql+asyncpg://', 'postgresql://')
    conn = await asyncpg.connect(url)
    
    # Check tables
    tables = await conn.fetch(
        "SELECT tablename FROM pg_tables WHERE schemaname='public' ORDER BY tablename"
    )
    print('Tables in Supabase:')
    for t in tables:
        print(' -', t['tablename'])
    
    # Check row counts
    for table in ['emergency_services', 'road_infrastructure', 'road_issues']:
        try:
            count = await conn.fetchval(f"SELECT COUNT(*) FROM {table}")
            print(f'  {table}: {count} rows')
        except Exception as e:
            print(f'  {table}: NOT FOUND - {e}')
    
    await conn.close()

asyncio.run(check())