parameterised query

A database query written with placeholders, such as WHERE id = ?, whose values are sent separately so they can never be read as SQL.

In more detail

It is the standard defence against SQL injection: the database treats the values strictly as data, whatever they contain. Most database drivers support it directly, and it is often called a prepared statement.

Example

cursor.execute('DELETE FROM tasks WHERE id=?', (task_id,))

Related terms

Taught in

References