MCPcopy Create free account
hub / github.com/explorerhq/sql-explorer / swap_params

Function swap_params

explorer/utils.py:64–70  ·  view source on GitHub ↗
(sql, params)

Source from the content-addressed store, hash-verified

62
63
64def swap_params(sql, params):
65 p = params.items() if params else {}
66 for k, v in p:
67 fmt_k = re.escape(str(k).lower())
68 regex = re.compile(rf"\$\${fmt_k}(?:\|([^\$\:]+))?(?:\:([^\$]+))?\$\$", re.I)
69 sql = regex.sub(str(v), sql)
70 return sql
71
72
73def extract_params(text):

Callers 4

final_sqlMethod · 0.90

Calls

no outgoing calls