feat: add supabase db

This commit is contained in:
qixinbo
2026-03-21 20:28:02 +08:00
parent cf19c9c12f
commit 7da0d9677e
6 changed files with 76 additions and 5 deletions
+3
View File
@@ -133,4 +133,7 @@ def test_datasource_connection(
else:
raise HTTPException(status_code=400, detail="Connection failed")
except Exception as e:
import traceback
import sys
print(f"Datasource Test Error: {str(e)}\n{traceback.format_exc()}", file=sys.stderr)
raise HTTPException(status_code=400, detail=f"Connection failed: {str(e)}")
+11 -3
View File
@@ -13,9 +13,17 @@ def _get_cached_connector(ds_type: str, config_json: str):
config = json.loads(config_json)
if ds_type in ["postgres", "postgresql", "supabase"]:
# Supabase is just postgres
db_url = config.get("connection_string") or \
f"postgresql://{config.get('user')}:{config.get('password')}@{config.get('host')}:{config.get('port', 5432)}/{config.get('database')}"
db_url = config.get("connection_string")
if not db_url:
default_port = 6543 if ds_type == "supabase" else 5432
port = config.get("port") or default_port
db_url = f"postgresql://{config.get('user')}:{config.get('password')}@{config.get('host')}:{port}/{config.get('database')}"
if ds_type == "supabase" and "?" not in db_url:
db_url += "?sslmode=require"
elif ds_type == "supabase" and "sslmode=" not in db_url:
db_url += "&sslmode=require"
return PostgresConnector(db_url=db_url)
elif ds_type == "sqlite":
+1 -1
View File
@@ -69,6 +69,6 @@ class PostgresConnector:
return True
except Exception as e:
print(f"PostgreSQL Connection Error: {e}")
return False
raise e
postgres_connector = PostgresConnector()
Binary file not shown.