Skip to content

Commit a596dfa

Browse files
interactive
1 parent cccd5f8 commit a596dfa

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

singlestoredb/functions/ext/asgi.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@
6666
from ..signature import signature_to_sql
6767
from ..typing import Masked
6868
from ..typing import Table
69+
from ...config import get_option
70+
6971

7072
try:
7173
import cloudpickle
@@ -1111,7 +1113,37 @@ def get_function_info(
11111113
sql_statement=sql,
11121114
)
11131115

1114-
return functions
1116+
# Parse database connection info safely
1117+
connection_info = {}
1118+
database_url = get_option('url')
1119+
if database_url:
1120+
from urllib.parse import urlparse
1121+
import re
1122+
1123+
parsed = urlparse(database_url)
1124+
1125+
# Extract service ID from hostname (e.g., svc-12345678-dml.aws-virginia-6.singlestore.com)
1126+
if parsed.hostname:
1127+
# Look for pattern like svc-xxxxxxxx-xxx
1128+
service_match = re.match(r'svc-([a-f0-9]{8})-', parsed.hostname)
1129+
if service_match:
1130+
connection_info['service_id'] = service_match.group(1)
1131+
else:
1132+
connection_info['service_id'] = None
1133+
1134+
# Extract database name from path
1135+
if parsed.path:
1136+
connection_info['database_name'] = parsed.path.lstrip('/')
1137+
1138+
# Don't include sensitive auth info
1139+
connection_info['host'] = parsed.hostname
1140+
connection_info['port'] = parsed.port
1141+
1142+
1143+
return {
1144+
'functions': functions,
1145+
'connection_info': connection_info
1146+
}
11151147

11161148
def get_create_functions(
11171149
self,

0 commit comments

Comments
 (0)