prepared statement

A SQL statement with placeholders, such as ?, whose values are sent separately from the SQL text instead of pasted into it.

In more detail

Because the database never parses the values as SQL, input like a name containing a quote cannot change the statement, which prevents SQL injection. It also lets the database reuse the parsed statement. Always bind values that come from users or other programs.

Examples

db.execute("SELECT body FROM doc WHERE owner = ?", (owner,))
INSERT INTO customers (name, city) VALUES (?, ?);

Related terms

Taught in

References