Skip to content

Language

Sign in

Python with MySQL: safe queries: activity sheet

Goal: Follow the connect, execute and fetch steps of a Python and MySQL program and see why placeholders beat joined strings.

You need: Only the simulation is needed. Do not try injection on any real database.

Safety: No special safety needs.

  1. Search for Asha with joined strings and fetchall.
  2. Search for O'Neil and note the error.
  3. Search for x' OR '1'='1 and note how many rows come back.
  4. Repeat with the placeholder and compare.
My observations
Query styleName typedFetchRows fetched

Use your browser's Print option to print this page.

Ask Flint AI
EduFlint: learn and play for free