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

Kyle Salisbury
Kyle Salisbury
Full Stack JavaScript Techdegree Student 16,347 Points

pycharm sqlite>.tables doesn't return anything. I know i'm stupid.lol

There has been a lot of posts on similar questions but I don't see what I'm doing wrong. I'm making a simple game and I wanted to store a players "money" that they get. I'm using pycharm and I'm in the terminal. My code:

from peewee import *
db = SqliteDatabase('money.db')

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

    class Meta:
        database = db

if __name__ == '__main__':
    db.create_tables([Money], safe=True)

from the terminal:

Microsoft Windows [Version 10.0.14393]
(c) 2016 Microsoft Corporation. All rights reserved.

D:\Programs\Python Projects\Bolton>sqlite3 money.db
SQLite version 3.19.3 2017-06-08 14:26:16
Enter ".help" for usage hints.
sqlite> .tables

So once I type in .tables it just goes right to sqlite> for some reason. Any ideas?

1 Answer

Kyle Salisbury
Kyle Salisbury
Full Stack JavaScript Techdegree Student 16,347 Points

So I just figured it out. I'm going to leave this up here in case other students are having the same problem. You have to actually run the code first. Don't just type it in like an idiot (which was me) and then try to find the table. You need to first run the code to generate a table. Then it will work.

Chris Freeman
Chris Freeman
Treehouse Moderator 68,064 Points

Correct! The create_tables has to be run to, say, create the tables! :smile: Good for posting this for others to see. Keep up the good work!