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 trial

Python Using Databases in Python Meet Peewee First Queries

Am I suppose to make an Instance or something else? What is it asking me to do here?

I'm still learning on how to use classes, and I thought I would just add an instance(?). Am I right to think that? Or do I need to do something else? Just looking for hints!

queries.py
from models import Challenge

all_challenges = Challenge.select()

all_challenges.Challenge(language="Ruby", name="Boolean")

1 Answer

Jeff Muday
MOD
Jeff Muday
Treehouse Moderator 28,722 Points

You're pretty close on the syntax, but we have to create a new challenge and save it to the database. The way I show below isn't the only way to do it.

Good luck with your Python journey!

from models import Challenge

# this has all Challenges from the database
all_challenges = Challenge.select()

# create a new single Challenge instance and SAVE it.
new_challenge = Challenge(language="Ruby", name="Booleans")
new_challenge.save()

Thank you for the help!