| 11 | return self.supabase_url |
| 12 | |
| 13 | async def get(self, table: str, columns: str, key_name: str, key_value): |
| 14 | logging.info(f"Retrieving {columns} for {key_name}: {key_value}") |
| 15 | |
| 16 | url = f"{self.supabase_url}/rest/v1/{table}?{key_name}=eq.{key_value}&select={columns}" |
| 17 | headers = { |
| 18 | "apiKey": self.supabase_key, |
| 19 | "Authorization": f"Bearer {self.supabase_key}", |
| 20 | } |
| 21 | |
| 22 | async with httpx.AsyncClient() as async_client: |
| 23 | response = await async_client.get(url, headers=headers) |
| 24 | |
| 25 | json = response.json() |
| 26 | if not response.is_success: |
| 27 | raise RuntimeError( |
| 28 | f"Error retrieving {columns=} from {table=} : {json['code']=}. {json['message']=}" |
| 29 | ) |
| 30 | |
| 31 | return json |
| 32 | |
| 33 | async def get_first(self, table: str, columns: str, key_name: str, key_value): |
| 34 | rows = await self.get(table, columns, key_name, key_value) |