ehsan-dashboards/dashboards/inspect_afriteh_metabase.py

31 lines
1.2 KiB
Python

import requests
import json
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=30)
data = res.json().get('data', {})
cols = [c['name'] for c in data.get('cols', [])]
rows = data.get('rows', [])
return cols, rows
# Get provider details for 141 and 1357
cols, rows = run_query("SELECT id, name, phone, card_number, iban FROM providers WHERE id IN (141, 1357)")
print("=== PROVIDERS FOR AFRITEH ===")
for row in rows:
print(dict(zip(cols, row)))
# Check settlement / payouts tables in metabase
cols, rows = run_query("SELECT table_name FROM information_schema.tables WHERE table_schema='public'")
all_tables = [r[0] for r in rows]
print("\n=== RELEVANT TABLES ===")
print([t for t in all_tables if any(k in t.lower() for k in ["settle", "payout", "transact", "wallet", "pay", "order", "factor", "refund", "return"])])