A console phone book in Python and SQLite: add, search, edit and delete contacts. A study project on working with a database.
A small console program: a phone book stored in SQLite.
It adds contacts, lists them, searches by name, city or number, and edits or deletes records. Output is laid out as a column-aligned table, every operation is wrapped in error handling, and query parameters are passed as placeholders rather than glued into the SQL string — which is the difference between a working program and one that breaks on the first apostrophe in a surname.
A study project, and honest about it. It covers the basics properly: connecting to a database, creating a table, parameterised queries, parsing input, and readable messages instead of a raw traceback.
A fragment of the project's real code — so you can see what's inside.
def create_table(): try: conn = sqlite3.connect("contacts.db") cursor = conn.cursor() cursor.execute(""" CREATE TABLE IF NOT EXISTS contacts ( id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, phone TEXT, city TEXT ) """) conn.commit() conn.close() except Exception as e: print("Ошибка:", e)def print_contacts(rows): if not rows: print("Контактов не найдено.") return print() print(f"{'ID':<4} {'Имя':<20} {'Телефон':<16} {'Город'}") print("-" * 55) for contact_id, name, phone, city in rows: print(f"{contact_id:<4} {name:<20} {phone:<16} {city or '-'}") print(f"\nВсего показано: {len(rows)}")Project request
Fill in the form — we'll discuss scope and timing.
Finite state machines in aiogram
