Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Using Databases in Python Our Diary App Doing Data Entry

Jordan Featherstone
Jordan Featherstone
5,973 Points

0 Results on .tables

I'm not sure why, but the tables don't seem to be saving in the database, i have scanned through my code and couldn't notice any errors. So i'm guessing its something very small that i cant put my finger on.

from peewee import *
 import datetime

db = SqliteDatabase('dairy.db')

class Entry(Model):
    content = TextField()
    timestamp = DateTimeField(default=datetime.datetime.now)

    class Meta:
        database = db

def init():
     db.connect()
     db.create_tables([Entry], safe=True)

def menu_loop():
     """ loop """

def add_entry():
    """add"""


def view_entries():
    """View pervious entries."""


def delete_entry(entry):
    """Delete an entry."""


if __name__ == '__main__':
    init()
    menu_loop()
Robin Burkett
Robin Burkett
3,642 Points

I noticed 2 typos, but they probably aren't the problem.

  1. import is indented one space
  2. diary.db is misspelled as dairy.db

What solved my problem when this happened to me was using the command "sqlite3 diary.db" to start sqlite3 instead of just "sqlite3".