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.connect()
  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__':
  initialize()
  menu_loop()

1 Answer

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

Your class Meta isn't in your class Entry.

doh...