""" Salesforce connector using CData JDBC bridge. Set env vars: SF_USER, SF_PASS, SF_TOKEN """ import os, json from cdata.salesforce import connect _conn = connect( User = os.getenv("SF_USER"), Password = os.getenv("SF_PASS"), SecurityToken = os.getenv("SF_TOKEN"), ) def sf_query(sql: str) -> str: """Execute SQL against Salesforce and return JSON rows.""" cur = _conn.cursor() cur.execute(sql) cols = [d[0] for d in cur.description] rows = [dict(zip(cols, r)) for r in cur.fetchall()] return json.dumps(rows)