Skip to content

Add a SQLite contact book using stdlib sqlite3 #23

Description

@utk2103

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

  • Parameterised queries only — 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 EXISTS so the script is safe to re-run.
  • Connection used as a context manager (or explicitly committed and closed).
  • argparse subcommands, not a menu of input() prompts.
  • contacts.db added to .gitignore.
  • Standard library only.

Inspiration

Database-As-Storage from Awesome-Python-Scripts.

Comment below to get assigned.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions