import urllib.request import json import ssl SUPA_URL = 'http://192.168.1.61:18000' SUPA_KEY = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiYW5vbiIsImlzcyI6InN1cGFiYXNlLTEiLCJpYXQiOjE3Njk2NzY0OTgsImV4cCI6MTkyNzM1NjQ5OH0.ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890' headers = { "apikey": SUPA_KEY, "Authorization": f"Bearer {SUPA_KEY}", "Content-Type": "application/json" } def get_one_row(table): try: url = f"{SUPA_URL}/rest/v1/{table}?select=*&limit=1" req = urllib.request.Request(url, headers=headers) context = ssl._create_unverified_context() with urllib.request.urlopen(req, context=context, timeout=5) as response: if response.status == 200: data = json.loads(response.read().decode()) if len(data) > 0: return data[0] else: return "Empty table" return f"Error {response.status}" except Exception as e: return str(e) print("\n[ml_user_coupons Columns]") print(get_one_row("ml_user_coupons")) print("\n[ml_products Columns]") print(get_one_row("ml_products"))