Download src/database.py from limloop/ru_characters_explorer: direct link, hf CLI and curl.
- Browser
- Download file 561 Bytes
-
https://huggingface.co/spaces/limloop/ru_characters_explorer/resolve/main/src/database.py
- Command line
-
hf download hf://spaces/limloop/ru_characters_explorer/src/database.py
-
curl -L -o database.py https://huggingface.co/spaces/limloop/ru_characters_explorer/resolve/main/src/database.py
561 Bytes
| import os | |
| import streamlit as st | |
| from supabase import create_client | |
| def init_supabase(): | |
| url = os.getenv("SUPABASE_URL") | |
| key = os.getenv("SUPABASE_KEY") | |
| return create_client(url, key) | |
| def get_hash(database, table, hash): | |
| try: | |
| return database.table(table).select("*").eq("hash", hash).execute() | |
| except Exception as e: | |
| return ([None, None], None) | |
| def upsert_data(database, table, data): | |
| try: | |
| return database.table(table).upsert(data).execute() | |
| except Exception as e: | |
| return {} |