Courses‎ > ‎Software Development‎ > ‎Dyrland-Weaver‎ > ‎Work‎ > ‎

Work 6: All about that database

posted Oct 13, 2016, 7:44 PM by JonAlf Dyrland-Weaver
With a partner of your choosing, grab the freshest sample code gift from the notes-n-code repo (right here: https://github.com/stuy-softdev/notes-and-code/tree/master/smpl/10_sqlite-smpl), and set about the mission below:

  • Read data from two CSV files --- one containing students and their IDs, another linking said IDs to the students' current grades in some courses --- and create a database whose table structure mimics that of the CSV files.
    • TASK the Foist: Familiarize yourself with Python's CSV module, specifically its DictReader() method, as it will greatly expedite your work going forward. (If you are already familiar, do your team a solid and lead a tutorial.)
      • For some sample code to get you going, see csv_tester.py
  • TASK the Second: Familiarize yourself with the contents of the two provided CSV files.
  • TASK the Toid: Write db_builder.py, which will
    • create a new SQLite database
    • utilize csv.DictReader() to read each provided CSV file
    • create a table for each
    • populate each table
  • Save your work in a new repo, linked under the db1 folder as TeamName_LastF-MastF-NastF
  • PROTIPs:
    • It may be helpful during development to delete your db file between runs.
    • Read through the db_builder skeleton AS A TEAM, and talk it over BEFORE you begin making it your own...
    • Use the sqlite shell to test out SQL commands before baking them into your Python script.

Comments