Parameterized Queries¶
⚠️ Not server-side prepare. pycubrid implements parameterized queries via client-side escape + interpolation, not via server-side
PREPARE/EXECUTE. This differs from JDBCPreparedStatement. See pycubrid PARAMETER_BINDING.md for the full 1.x binding contract.
This directory demonstrates safe parameterized query patterns using pycubrid's
qmark (?) placeholder style.
Recipes¶
| Recipe | Description |
|---|---|
04_parameterized.py |
Topic redirect → canonical recipe at ../pycubrid/04_prepared.py (parameterized queries, batch executemany(), SQL injection safety) |
Why parameterized queries?¶
Parameterized queries (passing values via ? placeholders and a separate
parameters argument) are the correct way to send user-supplied values to the
database. Never assemble SQL with f-strings or % formatting — that path
leads to SQL injection.
pycubrid binding model¶
When you call:
pycubrid:
- Splits the SQL on unquoted
?placeholders. - Formats each Python value as a SQL literal via
_format_parameter()(strings escaped via single-quote doubling,None→NULL, etc.). - Concatenates the segments and literals into one SQL string.
- Sends the fully-rendered SQL to CUBRID via
PrepareAndExecutePacket.
The CAS function code is named PREPARE_AND_EXECUTE, but the protocol expects
a complete SQL string — there is no separate typed parameter payload. See
pycubrid PARAMETER_BINDING.md
for the full per-type mapping and explicit non-guarantees.