From 105918784394c6c44f49352eed5e8ee946a86091 Mon Sep 17 00:00:00 2001 From: Matthew Huntington Date: Sun, 22 Oct 2023 17:17:11 -0400 Subject: [PATCH] updating psql to prevent injection --- python_sql/lessons/connect.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/python_sql/lessons/connect.md b/python_sql/lessons/connect.md index 56b5114..a6d2bad 100644 --- a/python_sql/lessons/connect.md +++ b/python_sql/lessons/connect.md @@ -11,7 +11,7 @@ ## Install a Python virtual environment -``` +```python python3 -m venv ~/my-env source ~/my-env/bin/activate ``` @@ -50,8 +50,8 @@ cursor.close() Select one -```ptyon -cursor.execute("SELECT * FROM people WHERE id = 12") +```python +cursor.execute("SELECT * FROM people WHERE id = %s", [24]) print(cursor.fetchone()) ``` @@ -65,7 +65,7 @@ conn.commit() Delete ```python -cursor.execute("DELETE FROM people WHERE id = 12"); +cursor.execute("DELETE FROM people WHERE id = %s", [24]); conn.commit() ``` @@ -75,3 +75,9 @@ Update cursor.execute("UPDATE people SET name = %s, age = %s WHERE id = %s", ['Matt', 43, 20]) conn.commit() ``` + +## Migrating data to a SQLite + +## Exporting data to CSV + +