Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sqlite3
- # Connect to the database
- conn = sqlite3.connect("quests.db")
- cursor = conn.cursor()
- # Create the table if it doesn't exist
- cursor.execute('''
- CREATE TABLE IF NOT EXISTS quests (
- id INTEGER PRIMARY KEY AUTOINCREMENT,
- name TEXT NOT NULL,
- description TEXT,
- completed INTEGER DEFAULT 0
- )
- ''')
- conn.commit()
- # === Menu Loop ===
- def main():
- while True:
- print("\n=== Quest Tracker ===")
- print("1. Add Quest")
- print("2. View Quests")
- print("3. Mark Quest as Completed")
- print("4. Delete Quest")
- print("5. Exit")
- choice = input("Choose an option: ")
- if choice == "1":
- add_quest()
- elif choice == "2":
- view_quests()
- elif choice == "3":
- complete_quest()
- elif choice == "4":
- delete_quest()
- elif choice == "5":
- break
- else:
- print("Invalid choice.")
- conn.close()
- # === Functions to be completed ===
- def add_quest():
- # TODO: Prompt for name/description and insert into database
- pass
- def view_quests():
- # TODO: Fetch and print all quests from the database
- pass
- def complete_quest():
- # TODO: Mark a quest as completed using its ID
- pass
- def delete_quest():
- # TODO: Delete a quest from the database using its ID
- pass
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement