Search code examples
pythonsqlitepeewee

Python: Peewee Update Query is not working


I use pewee and the following queries:

 for row in Group.select():
    group_data = process_group(row.link)
    Group.update(name=group_data[0], type=group_data[1], member=group_data[2]).where(Group.id==1)

for row in Group.select():
    group_data = processl_group(row.link)
    Group.update(name=group_data[0], type=group_data[1], member=group_data[2]).where(Group.link==row.link)

Group - is the table name ; name,type,member,link - are the columns database - sqllite

I tested separately if group_data values exit and are ok, now issue Group.id= 1 ; exist

I have no idea what is the problem. Please help.


Solution

  • You need to call .execute() at the end of your query:

    for row in Group.select():
        group_data = process_group(row.link)
        (Group
         .update(name=group_data[0], type=group_data[1], member=group_data[2])
         .where(Group.id==1)
         .execute()) # Added .execute