Script Development / SQL Construction DFF.SQL
DFF.SQL(...) is used to construct parameterized SQL, avoiding inserting user input via string concatenation. Most SQL connectors already have this capability built in, and you can directly call conn.query(sql, sql_params=...) or conn.non_query(...).
Only when you need to explicitly format SQL for debugging, or when the caller must receive the final SQL string, do you need to call DFF.SQL(...) separately.
Parameters and Placeholders
| Parameter | Type | Required / Default | Description |
|---|---|---|---|
sql |
str | Required | SQL statement containing parameter placeholders |
sql_params |
list | None |
SQL parameters provided in placeholder order |
| Placeholder | Meaning | Example result |
|---|---|---|
? |
Value parameter, escaped and quoted | 'user-001' |
?? |
Identifier or SQL fragment, not quoted | users |
| Example | |
|---|---|
1 2 3 4 5 | |
?? does not protect untrusted input
User input must be placed in ?. Identifiers such as table names and field names can be placed in ?? only if they come from an allowlist or trusted configuration. Do not insert SQL values via f-strings or string concatenation.
Parameter Expansion
Array parameters are automatically expanded into multiple values, and two-dimensional arrays are expanded into multiple rows of values:
| Array Expansion | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 | |
Dictionary parameters are expanded into multiple assignment expressions:
| Dictionary Expansion | |
|---|---|
1 2 3 4 5 | |
Before executing dynamic write or delete SQL, re-confirm the target table and filter conditions.