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 trialCross Ender
9,567 PointsI 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
KRIS NIKOLAISEN
54,967 PointsYou misspelled cheese (cheease) here:
PizzaOrder.create(name=name, lunches=lunches, extra_slices=extra_slices,
slices=slices, pepperoni=pepperoni, cheease=cheese, price=price)
Alexander Davison
65,469 PointsAlexander Davison
65,469 PointsBingo!