使用sqlite db在peewee中将字符串与原子更新连接起来
concatenate strings with atomic update in peewee using sqlite db
我想更新使用 peewee python 库创建的 sqlite 数据库中的文本字段。具体来说,我想使用 peewee 的原子更新,例如:
query = Table.update(textfield = Table.textfield + 'string').where(some condition)
query.execute()
这种类型的更新适用于数字字段但不适用于文本字段。我猜 sqlite 可能有办法做到这一点 ||运算符,但由于 sql 通常对我来说有些陌生,所以我无法弄明白。
您可以使用 concat 运算符:
query = Table.update(textfield=Table.textfield.concat('string')).where(whatever)
query.execute()
concat
运算符将在后台使用 ||
。
我想更新使用 peewee python 库创建的 sqlite 数据库中的文本字段。具体来说,我想使用 peewee 的原子更新,例如:
query = Table.update(textfield = Table.textfield + 'string').where(some condition)
query.execute()
这种类型的更新适用于数字字段但不适用于文本字段。我猜 sqlite 可能有办法做到这一点 ||运算符,但由于 sql 通常对我来说有些陌生,所以我无法弄明白。
您可以使用 concat 运算符:
query = Table.update(textfield=Table.textfield.concat('string')).where(whatever)
query.execute()
concat
运算符将在后台使用 ||
。