def set_multiple_values(prices):
""" Update all prices with their new values
Note: this function should be prefered when dealing with multiple prices at
once for performance purposes.
:param list prices: List of prices
"""
with Database() as database:
database.transaction()
cursor = QtSql.QSqlQuery(database)
cursor.prepare("UPDATE prices SET value=:value WHERE id=:id")
for price in prices:
cursor.bindValue(":id", price['id'])
cursor.bindValue(":value", price['value'])
cursor.exec_()
database.commit()
return True
评论列表
文章目录