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
- SQL injection — An attack where untrusted input is joined into a database query so that part of it runs as SQL, letting an attacker read or change data.
- SQL — The standard language for defining, querying and changing data in a relational database.
Taught in
- Security Best Practices — Modern API Architecture: REST, GraphQL & gRPC