peewee update 的封装调用问题
时间: 2020-08-27来源:V2EX
前景提要
假设我的数据模型: class Book(Model): id = PrimaryKeyField() title = CharField(max_length=64, unique=True) author = CharField(max_length=64) publisher = CharField(max_length=64) price = DecimalField(max_digits=10, decimal_places=2) desc = CharField(max_length=256)
如果我要根据条件更新的话, 找了很多文档基本都是:
Book.update({Book.price: 29.9}).where(Book.author == '鲁迅')
但外部调用的话只能提供字段名比如 {'price': 29.9}, {'author': '鲁迅'}, 怎样才能拼出上边的语句?

科技资讯:

科技学院:

科技百科:

科技书籍:

网站大全:

软件大全:

热门排行