简体   繁体   中英

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM