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, db=2): res = requests.post('https://metabase.ekeepa-dev.ir/api/dataset', headers=headers, json={ 'database': db, '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 cols, rows = run_query("SELECT id, name, family, phone_number, national_code FROM users WHERE national_code LIKE '%3241869490%' OR family LIKE '%شهلائ%' OR name LIKE '%شهاب%'") print("Users:", rows) cols, rows = run_query("SELECT id, name, owner_national_number, owner_full_name, city, telephone FROM providers WHERE owner_national_number LIKE '%3241869490%' OR owner_full_name LIKE '%شهلائ%'") print("Providers:", rows)