Add a contact-book script backed by SQLite, using the standard library sqlite3 module.
Why
The notebooks cover files, JSON, and pickle for persistence. SQLite is the next honest step and it needs no install and no server — sqlite3 ships with Python. This is where a beginner learns why a database beats rewriting a whole JSON file on every change.
Suggested file
scripts/contact_book_sqlite.py
What it should do
- Subcommands:
add, list, search, delete.
python scripts/contact_book_sqlite.py add --name "Ada" --phone 555000 --email ada@x.com
python scripts/contact_book_sqlite.py search --name ada
- Create
contacts.db (git-ignored) on first run.
Acceptance criteria
Inspiration
Database-As-Storage from Awesome-Python-Scripts.
Comment below to get assigned.
Add a contact-book script backed by SQLite, using the standard library
sqlite3module.Why
The notebooks cover files, JSON, and
picklefor persistence. SQLite is the next honest step and it needs no install and no server —sqlite3ships with Python. This is where a beginner learns why a database beats rewriting a whole JSON file on every change.Suggested file
scripts/contact_book_sqlite.pyWhat it should do
add,list,search,delete.python scripts/contact_book_sqlite.py add --name "Ada" --phone 555000 --email ada@x.com python scripts/contact_book_sqlite.py search --name adacontacts.db(git-ignored) on first run.Acceptance criteria
cur.execute("… WHERE name LIKE ?", (pattern,)). No f-strings or%in SQL. Add a comment explaining SQL injection, since that's the whole lesson.CREATE TABLE IF NOT EXISTSso the script is safe to re-run.argparsesubcommands, not a menu ofinput()prompts.contacts.dbadded to.gitignore.Inspiration
Database-As-Storage from Awesome-Python-Scripts.
Comment below to get assigned.