HW1: CRUD Operations
Due: Monday, Sep 2nd
Image source:
Charles Leifer blog
CRUD is an acronym that stands for Create, Read, Update, and Delete—the four basic operations of persistent storage. In this assignment, you will write a program that performs CRUD operations on a table of your choice. You will become familiar with executing SQL statements in Python.
Objectives¶
- Write simple
CREATE TABLE
,INSERT
,UPDATE
, andDELETE
statements. - Use Python's DB-API to execute queries and fetch results from SQLite.
Instructions¶
Download the provided hw1.py template.
Implement each of the functions as described in the docstrings.
Notice that, for some of the functions, you will need to add parameters.
Modify the provided code under __main__
to call each function with reasonable arguments.
Be sure to complete all tasks specified in the TODO
comments.
Run your code offline before submitting to Gradescope.
You may find the following documentation and tutorial pages useful:
- sqlite3 Python Module
- SQL CREATE TABLE
- Data Types in SQLite
- SQL INSERT Statement
- SQL SELECT Statement
- SQL UPDATE Statement
- SQL DELETE Statement
Submission¶
Submit your hw1.py
to the HW1 assignment on Gradescope.
Your code will first be graded by Gradescope and then by the professor. The grade you receive from Gradescope is the maximum grade that you can receive on the assignment.
After the due date, the professor may manually review your code. At that time, points may be deducted for inelegant code, inappropriate variable names, bad comments, etc.
Gradescope will provide you with hints but might not completely identify the defects in your submission. You are expected to test your own code before submitting.
There is no limit on the number of submissions and no penalty for excessive submissions. Points will be allocated as follows:
Criterion | Points | Details |
---|---|---|
Autograder | 80 pts | Partial Credit Possible |
Code Review | 20 pts | Partial Credit Possible |
The code review will include:
- Your table's design (column names and data types).
- The sample data in you wrote in
insert_sample()
. - Additions you made to the provided docstrings.
- Changes you made to the code under
__main__
.