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.
- Search for Asha with joined strings and fetchall.
- Search for O'Neil and note the error.
- Search for x' OR '1'='1 and note how many rows come back.
- Repeat with the placeholder and compare.
| Query style | Name typed | Fetch | Rows fetched |
|---|---|---|---|
Use your browser's Print option to print this page.