def updateNurseSpecification():
nurse_lname = input("\nEnter the last name of the nurse "
"you would to update: \n")
query = c.execute('SELECT fname, lname, specification FROM Nurses '
'WHERE lname LIKE ?', (nurse_lname,))
new_spec = input("\nEnter the updated specification of this employee: \n")
query1 = c.execute('UPDATE Nurses SET specification = ', (new_spec,)
' WHERE lname LIKE ?', (nurse_lname,))
我不知道使用变量“new_spec”更新记录的语法。
print("Your update is as shown: \t")
query2 = c.execute('SELECT fname, lname, specification FROM Nurses'
'WHERE lname LIKE ?', (nurse_lname,))
答案 0 :(得分:2)
execute
有两个参数 - 一个SQL字符串和一个参数元组:
c.execute('UPDATE Nurses SET specification = %s WHERE lname LIKE %s',
(new_spec, nurse_lname))