1

I am making a peewee database. In my python code I try to retrieve rows from the model that may be empty:

player_in_db = Player.select().where(Player.name == player.name_display_first_last)

Player is the name of the model

name is a field instance in Player defined...

class Player(Model):
      name = CharField()

player.name_display_first_last is a string

I get an error that says peewee.OperationalError: no such column: t1.name

I've been trying to solve this problem for the bulk of today, but to no avail. Any help would be much appreciated. Let me know if you need any more information to help me. Thanks.

leojacoby
  • 75
  • 8

1 Answers1

0

The error says you're missing the name column in the table (named t1) that your Player model uses. Most likely you've told PeeWee to create the table for player before it had the name field or you simply haven't created the table at all. You should always try to fully write your model before creating it's table.

If you're just using test data for now, you can use drop_table() to delete the entire table and then re-create it with create_tables().

drop_tables(Player)
create_tables([Player])
Soviut
  • 88,194
  • 49
  • 192
  • 260
  • What I did was I defined the model, and then said: – leojacoby Oct 16 '16 at 06:31
  • Sorry I entered that by mistake. I defined the class and then created the table: `db.create_tables([Player], safe=True)`. When should I define the name field? – leojacoby Oct 16 '16 at 06:33