SimpleClient Todo App

A minimal to-do application using auto-created tables.

Full Source

 1"""
 2SimpleClient Todo App
 3
 4A minimal to-do application using auto-created tables.
 5"""
 6
 7import sqbooster
 8
 9
10def main():
11    with sqbooster.sqlite() as db:
12
13        print("=== Todo App ===\n")
14
15        db.add("todos", [
16            {"title": "Buy groceries", "done": False, "priority": 1},
17            {"title": "Write docs", "done": False, "priority": 2},
18            {"title": "Fix bug #42", "done": True, "priority": 3},
19            {"title": "Review PR", "done": False, "priority": 2},
20            {"title": "Deploy v2.0", "done": False, "priority": 3},
21        ])
22
23        print("--- Pending Tasks ---")
24        pending = db.find("todos", done=False, order_by="-priority")
25        for t in pending:
26            print(f"  [P{t['priority']}] {t['title']}")
27
28        db.update("todos", {"done": True}, title="Write docs")
29        print("\nCompleted: Write docs")
30
31        total = db.count("todos")
32        done = db.count("todos", done=True)
33        print(f"\nProgress: {done}/{total} done")
34
35        bug = db.get("todos", title__contains="bug")
36        if bug:
37            print(f"Found bug task: {bug['title']} (priority={bug['priority']})")
38
39        removed = db.remove("todos", done=True)
40        print(f"\nCleaned up {removed} completed tasks")
41
42        print("\n--- Remaining Tasks ---")
43        for t in db.find("todos", order_by="-priority"):
44            status = "done" if t["done"] else "todo"
45            print(f"  [{status}] [P{t['priority']}] {t['title']}")
46
47    print("\nDone!")
48
49
50if __name__ == "__main__":
51    main()

What It Demonstrates

  • Auto-created tables from the data you insert

  • Top-level factory - sqbooster.sqlite()

  • Filter operators like __contains for partial matching

  • Ordering with -priority for descending sort

  • Update specific rows by filter

  • Count with and without filters

  • Remove rows matching a condition

Running the Example

python examples/simple_todo.py