import requests url = 'https://metabase.ekeepa-dev.ir/api/session' creds = {'username': 'Fallahi.hamed@gmail.com', 'password': 'r5kivS&JR4d2BfUaS95xCDY^NxX*'} r = requests.post(url, 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=60) data = res.json().get('data', {}) cols = [c['name'] for c in data.get('cols', [])] rows = data.get('rows', []) return cols, rows # 1. Query v_hamed for afriteh sql = """ SELECT roomid, otagh, brand, status, payment_status, payment_status_title, count(*) as cnt, sum(paid_amount) as total_paid FROM v_hamed WHERE otagh LIKE '%عفریته%' OR otagh LIKE '%افریته%' OR roomid IN (50135711, 1014111, 1014112) GROUP BY roomid, otagh, brand, status, payment_status, payment_status_title """ cols, rows = run_query(sql) print("=== V_HAMED SUMMARY FOR AFRITEH ===") for r in rows: print(dict(zip(cols, r))) # 2. Check distinct payment_status_title across all v_hamed to see what refund/return titles exist cols_st, rows_st = run_query("SELECT status, payment_status, payment_status_title, count(*) FROM v_hamed GROUP BY status, payment_status, payment_status_title") print("\n=== ALL PAYMENT STATUS TITLES IN V_HAMED ===") for r in rows_st: print(dict(zip(cols_st, r)))