Member-only story
Key Points
- Basic commands and operations
- SQL data types
- Making SQL queries in Python programmes
- Multiple tables
- SQL injection attack
Assignment: Houses
import.py
Spec:
Write a programme that imports data from a CSV spreadsheet. For each student in the CSV file, insert the student into the
students
table in thestudents.db
database.While the CSV file provided to you has just a
name
column, the database has separate columns forfirst
,middle
, andlast
names. You’ll thus want to first parse each name and separate it into first, middle, and last names. For students without a middle name, you should leave theirmiddle
name field asNULL
in the table.
Reading a CSV file with DictReader
, each row will be turned into a dictionary, with column names being the keys and their corresponding values being values.
{‘name’: ‘Adelaide Murton’, ‘house’…