Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python

I want to write an original program, and this happens

Hello.

My mom volunteers at something called eDay to be the Pizza Coordinator because eDay sells pizza lunches. Generally she will ask for people to write data onto a piece of paper. When she's done, she has to do a bunch of math.

My goal is to write a program to do 80% of her job for her. This will involve writing to a sqlite database. Here's my code so far:

========================================================================

from peewee import *

db = SqliteDatabase('orders.db')

class PizzaOrder(Model):
    name = CharField(max_length=60)
    lunches = IntegerField()
    extra_slices = IntegerField()
    slices = IntegerField()
    pepperoni = IntegerField()
    cheese = IntegerField()
    price = IntegerField()

    class Meta:
        database = db

def create_pizza_order(name, lunches, extra_slices, pepperoni):
    slices = lunches + extra_slices
    cheese = slices - pepperoni
    price = (lunches * 2) + extra_slices

    PizzaOrder.create(name=name, lunches=lunches, extra_slices=extra_slices,
                      slices=slices, pepperoni=pepperoni, cheease=cheese, price=price)

if __name__ == "__main__":
    db.connect()
    db.create_tables([PizzaOrder], safe=True)

========================================================================

But, every time I run create_pizza_order() I get this error:

sqlite3.IntegrityError: NOT NULL constraint failed: pizzaorder.cheese

Please help me! I promised my mom I would push this out by the next eDay.

[MOD: added ```python formatting -cf]

1 Answer

You misspelled cheese (cheease) here:

PizzaOrder.create(name=name, lunches=lunches, extra_slices=extra_slices,
                  slices=slices, pepperoni=pepperoni, cheease=cheese, price=price)

Bingo! :grin: