Python Using Databases in Python Our Diary App Doing Data Entry

Jeffrey Covington
Jeffrey Covington
6,540 Points

Attribute Error

After running the script I get the following:

Traceback (most recent call last):
  File "journal.py", line 40, in <module>
    initialize()
  File "journal.py", line 21, in initialize
    db.create_tables([Entry], safe=True)
  File "/Users/jeffreycovington/anaconda/lib/python3.5/site-packages/peewee.py", line 3826, in create_tables
    create_model_tables(models, fail_silently=safe)
  File "/Users/jeffreycovington/anaconda/lib/python3.5/site-packages/peewee.py", line 5268, in create_model_tables
    for m in sort_models_topologically(models):
  File "playhouse/_speedups.pyx", line 345, in playhouse._speedups.sort_models_topologically (playhouse/_speedups.c:7144)
  File "stringsource", line 67, in cfunc.to_py.__Pyx_CFunc_tuple____object___to_py.wrap (playhouse/_speedups.c:8293)
  File "playhouse/_speedups.pyx", line 327, in playhouse._speedups._sort_key (playhouse/_speedups.c:6704)
AttributeError: type object 'Entry' has no attribute '_meta'

Note: I called my file journal.py

Any ideas?

[MOD: added ```python formatting -cf]

Jonathon Grant
Jonathon Grant
21,526 Points

can you please provide your script here for review?

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 55,557 Points

Did you include the Meta definition in the Entry class definition:

class Entry(Model):

    class Meta:
        database = db