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

Has anyone got this program to work in an IDE other than Workspace?

Maybe my last question was a bit too detailed. Has anyone got the code from this video to work in an IDE other than workspace and if so, is there some special configuration that needs to be implemented.

Near the end of the video at 5:56 in, the teacher types in "ls" Why I type "ls" into an Interactive Console, I get a Traceback error telling me "ls' which returns the python file and a database file students.db and students.py. Doing the same thing I get a Traceback error that tells me that "ls" is not defined.

from peewee import *

db = SqliteDatabase('students.db')

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

    class Meta: 
        database = db


if __name__ == '__main__':
    db.connect()
    db.create_table([Student], safe=True)

2 Answers

Martin Cornejo Saavedra
Martin Cornejo Saavedra
18,132 Points

To get this to work in your workstation, you have to install peewee module. To install python modules in an easy way, install pip https://pypi.python.org/pypi/pip install peewee http://docs.peewee-orm.com/en/latest/peewee/installation.html

And about 'ls', it is a command for the linux console, not the python console. 'ls' shows a list of the current files and folders in the path.

Thanks Martin. I was able to install peewee ok. I am just finding it difficult to transition from the Workspace to an IDE and this database module. I can't expect the linux commands to work in a Windows console.

Bogdan Lalu
Bogdan Lalu
6,419 Points

Hi rodian. Maybe this is too late for you but hopefully it may help others in the future. I confirm that all of this works with the PyCharm IDE. I am personally using the Anaconda package which includes Python plus various libraries and modules. I have installed peewee using pip and sqlite3 using the 'conda install sqlite' command in the Windows command prompt. Sure, you can't expect Linux commands such as LS to work in a Windows console but what you could do is either use Windows Explorer to check the files or use the windows specific command to list the files in a folder which is DIR.