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

Script is creating two .db files

My diary.py script is creating a diary.db and a peewee.db file, but only putting tables into peewee.db. I have rm -r on the dbs and tried it locally on my own machine with the same effect. Students.py script does not do this.

import datetime

from peewee import *

db = SqliteDatabase('diary.db')

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

def initialize():
  """Create the database and the table if the don't exist."""
  db.create_tables([Entry], safe=True)

class Meta:
  database = db

def menu_loop():
  """Show the menu"""

def add_entry():
  """Add an entry"""

def view_entries():
  """View previous entries"""

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

if __name__ == '__main__':

1 Answer

Kenneth Love
Kenneth Love
Treehouse Guest Teacher

Your class Meta isn't in your class Entry.