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.
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])