import requests import json creds = {'username': 'Fallahi.hamed@gmail.com', 'password': 'r5kivS&JR4d2BfUaS95xCDY^NxX*'} r = requests.post('https://metabase.ekeepa-dev.ir/api/session', json=creds, timeout=15) token = r.json().get('id') headers = {'X-Metabase-Session': token} def run_query(sql): res = requests.post('https://metabase.ekeepa-dev.ir/api/dataset', headers=headers, json={ 'database': 2, 'type': 'native', 'native': {'query': sql} }, timeout=30) data = res.json().get('data', {}) cols = [col['name'] for col in data.get('cols', [])] rows = data.get('rows', []) return cols, rows # 1. Search for 10661311 across room/game/experience tables or search by ID cols, rows = run_query(""" SELECT table_name FROM information_schema.tables WHERE table_schema='public' ORDER BY table_name; """) tables = [row[0] for row in rows] print("Tables count:", len(tables)) # Look for room tables room_tables = [t for t in tables if any(k in t.lower() for k in ['room', 'game', 'experience', 'package', 'event', 'product'])] print("Relevant tables:", room_tables) # Let's check table structures or search for 10661311 for t in room_tables: cols, rows = run_query(f"SELECT column_name, data_type FROM information_schema.columns WHERE table_name = '{t}'") col_names = [r[0] for r in rows] # If id exists, query 10661311 if 'id' in col_names: c, r = run_query(f"SELECT * FROM {t} WHERE id = 10661311 LIMIT 1") if r: print(f"FOUND in {t} (id=10661311):", dict(zip(c, r[0]))) # Also search for 'دوکبوکی' or 'kfl' or 'پخت' in relevant tables for t in room_tables: cols, rows = run_query(f"SELECT column_name, data_type FROM information_schema.columns WHERE table_name = '{t}'") text_cols = [r[0] for r in rows if 'char' in r[1] or 'text' in r[1]] for tc in text_cols[:3]: # check first few text cols try: c, r = run_query(f"SELECT id, {tc} FROM {t} WHERE {tc} LIKE '%دوکبوکی%' OR {tc} LIKE '%kfl%' LIMIT 5") if r: print(f"FOUND match in {t}.{tc}:", r) except Exception as e: pass