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 Using Databases in Python Meet Peewee Modeling

Yuyang Peng
Yuyang Peng
5,665 Points

things from peewee may be undefined or defined from star imports

Hey guys, I m using spyder3 and typed the code Kenneth did, but it tells me that they are all not defined. Anyone please :(

Dave StSomeWhere
Dave StSomeWhere
19,822 Points

Could you please post the code and the error message

Yuyang Peng
Yuyang Peng
5,665 Points

Thank you Dave from peewee import *

db = SqliteDatabase('students.db')

class Student(Model): username = CharField(max_length=255, unique=True) points = IntergerField(default=0)

class Meta:
    database = db

if name == 'main': db.connect() db.create_tables([Student], safe=True)

File "C:/Users/Tommy/.spyder-py3/peeweepractice.py", line 16, in Student points = IntergerField(default=0)

NameError: name 'IntergerField' is not defined

3 Answers

You probably need to install peewee via:

pip3 install peewee
Yuyang Peng
Yuyang Peng
5,665 Points

Thank you Alex, Yeah I ve already installed that, but still it doesnt work, wishing I could post a screenshot but it won't allow me

Yuyang Peng
Yuyang Peng
5,665 Points

So I just downloaded and installed mySQL, is it right that we need it installed? How do we use it? Cuz my spyder still gives me error

Yuyang Peng
Yuyang Peng
5,665 Points

Okay I am so freaking embarrassed right now, cuz I had a typo there.......I typed interger instead of integer.....problem solved everyone..... Thank you all for commenting and trying to help me out !