[英]How to update multiple records using peewee
是的,您可以使用insert_many()
函数:
一次插入多行。 rows参数必须是可迭代的,可以产生字典。 与insert()一样,字典中未指定的字段将使用其默认值(如果存在)。
例:
usernames = ['charlie', 'huey', 'peewee', 'mickey']
row_dicts = ({'username': username} for username in usernames)
# Insert 4 new rows.
User.insert_many(row_dicts).execute()
有关更多详细信息,请访问: http : //docs.peewee-orm.com/zh_CN/latest/peewee/api.html#Model.insert_many
ORM通常不支持批量更新,您必须使用自定义SQL,您可以在此链接中看到示例(db.excute_sql)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.