Member-only story

[CS] CS50 Week 7: SQL

Penny N.
2 min readNov 24, 2020

--

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 the students.db database.

While the CSV file provided to you has just a name column, the database has separate columns for first, middle, and last 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 their middle name field as NULL 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’…

--

--

Penny N.
Penny N.

Written by Penny N.

A passionate self-taught  iOS developer. Write to record my learning and share the knowledge

No responses yet