我试图在参数中使用字典来调用存储过程来更新使用字典中的值作为外键的表。字典数据(ID 是外键)例如:server1, ID1 server5, ID2ID 是我试图更新的表上的外键,在调用存储过程时需要作为参数。看来,当我将字典作为参数传入时,它正在拉取 server1 而不是 ID1 并导致密钥错误。with open('DBstatus.csv') as dbcsvfile: dbstatus = csv.DictReader(dbcsvfile) for row in dbstatus:#Create parameters for stored procedure guardpointparams = (row['FS Agent Registration Status'], row['FS Agent Version'], row['Guard Path'], serverdict[row['Host Name']], policydict[row['Policy Name']], 0) #call stored procedure updateguardpointstable = cursor.callproc('update_guardpoints', guardpointparams)#i created the dictionary from a different script while updating the "servers" table where the DB is creating the returnvalue (ID) from the stored procedure see sample below:serverdict[row['Host Name']] = returnvalue[3]回溯:guardpointparams = (row['FS Agent Registration Status'], row['FS Agent Version'], row['Guard Path'], serverdict[row['Host Name']], policydict[row['Policy Name] ']], 0) KeyError: 'server1'
添加回答
举报
0/150
提交
取消