def transactions(notes, diff, *, do_not=False):
""" Change the note on multiple notes
:param str nickname: The nickname of the note
:param float diff: Will add the diff to the note.
:return bool: True if success else False
"""
with Database() as database:
database.transaction()
cursor = QtSql.QSqlQuery(database)
cursor.prepare("UPDATE notes SET note=note+:diff WHERE nickname=:nick")
for nick in notes:
cursor.bindValue(':nick', nick)
cursor.bindValue(':diff', diff)
cursor.exec_()
value = database.commit()
if not do_not:
api.redis.send_message("enibar-notes", notes)
return value
评论列表
文章目录