简体   繁体   English

Python:Peewee Update Query无效

[英]Python: Peewee Update Query is not working

I use pewee and the following queries: 我使用pewee和以下查询:

 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 name,type,member,link - 是列数据库 - sqllite

I tested separately if group_data values exit and are ok, now issue Group.id= 1 ; 如果group_data值退出并且没有问题,我会单独测试,现在发出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: 您需要在查询结束时调用.execute()

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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