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 Modeling

Kyle Salisbury
seal-mask
.a{fill-rule:evenodd;}techdegree
Kyle Salisbury
Full Stack JavaScript Techdegree Student 16,363 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.connect()
    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
sqlite>

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

1 Answer

Kyle Salisbury
seal-mask
.a{fill-rule:evenodd;}techdegree
Kyle Salisbury
Full Stack JavaScript Techdegree Student 16,363 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,457 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!