What I Did on Day One of Building My Study Buddy AI
- Created a Database Every app that needs to remember things needs a database. In my case, I want my AI Study Buddy to:
Store my courses (Math, Physics, etc.)
Store materials I upload weekly.
Keep track of my struggles (things I find difficult).
Save questions + answers (so it can test me later).
Record my calendar events (like midsems).
- Wrote Python Code to Create Tables I used sqlite3 (Python’s built-in database library) to create the database.
Here’s what each table does:
courses → list of all my subjects.
materials → weekly content I upload.
struggles → what I find hard that week.
questions → AI-generated or manual test questions.
answers → my answers and whether they were correct.
calendar → my upcoming academic events.
Think of tables as Excel sheets, but inside Python.
- Inserted My First Course I tested the database by inserting "Mathematics" into the courses table.
c.execute("INSERT INTO courses (name) VALUES (?)", ("Mathematics",))
This means:
INSERT INTO courses (name)
→ I’m filling the column name in the courses table.
VALUES (?)
→ The ? is a placeholder for safe input.
("Mathematics",)
→ The actual value to insert.
- Fetched My First Row
Then I asked the database:
c.execute("SELECT * FROM courses")
print("Courses:", c.fetchall())
SELECT * FROM courses
→ Get everything from the courses table.
fetchall()
→ Collect all rows into Python.
print(...)
→ Show results.
Output looked like:
Courses: [(1, 'Mathematics')]
1 = the ID (auto-assigned by database).
'Mathematics' = the course name.
So now my Study Buddy officially knows I have a Math course
Top comments (0)