$ ./guess_the_languageSQL & Databases
SQL & Databases · medium · #51

Why does this not work for choosing the table?

# Python DB-API
cur.execute("SELECT * FROM %s", (table,))
  1. Placeholders bind values, not names
  2. SELECT * can never take a parameter
  3. Tuples can't hold string values
  4. %s only works for integers
Bound parameters are data, never identifiers; validate table names against an allowlist instead.
Play SQL & Databases ▸