Python Using Databases in Python Our Diary App Switching It Up

Ashley Keeling
Ashley Keeling
11,475 Points

the quit part of the function isn't working

i am not sure if it is supposed to but in the video it worked for him, everything else is working

!/usr/bin/env python3

from collections import OrderedDict import datetime

from peewee import *

db = SqliteDatabase('diary.db')

class Entry(Model): content = TextField() # content timestamp = DateTimeField( # timestamp

class Meta:
    database = db

def initialize(): """create the database and the table if they font exist""" db.connect() db.create_tables([Entry], safe=True)

def menu_loop(): """SHOW THE MENU""" choice = None

while None != 'q':
    print("enter 'q' to quit")
    for key, value in menu.items():
        print("{}) {}".format(key, value.__doc__))
    choice = input('Action: ').lower().strip()

    if choice in menu:

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

def view_entries(): """view previous enteries"""

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

menu = OrderedDict([ ('a', add_entry), ('v', view_entries), ])

if name=='main': initialize() menu_loop()

1 Answer

while None != 'q':

did you meant choice != 'q'