Below are my SQL TABLE and DATAFRAME:
TXN_KEY SEND_AGENT Pay_Agent
13273870 ANO080012 NULL
13274676 AUK359401 NULL
13274871 ACL000105 NULL
13275398 AED420319 NULL
13278566 ARA030210 NULL
13278955 AYM003098 NULL
13280334 AJ5020114 NULL
13280512 A11171047 NULL
13281278 AOG010045 NULL
13282118 AMX334165 NULL
In [212]: df
Out[212]:
TXN_KEY SEND_AGENT PAY_AGENT
13273870 ANO080012 API352676
13274676 AUK359401 AED002782
13274871 ACL000105 ACB020203
13275398 AED420319 ASE094882
13278566 ARA030210 AII071196
13278955 AYM003098 AHX012817
13280334 AJ5020114 AED000438
13280512 A11171047 AEL051943
13281278 AOG010045 ADJ031448
13282118 AMX334165 APM033226
Below cursor statement is adding the first value of Pay_Agent in sql server just fine
cursor.execute("""update result SET Pay_Agent = ? WHERE SEND_AGENT = ?""",df['PAY_AGENT'][0],df['SEND_AGENT'][0])
13273870 ANO080012 API352676
13274676 AUK359401 NULL
13274871 ACL000105 NULL
13275398 AED420319 NULL
-------
How do I code this cursor statement in a for loop to iterate over the entire dataframe and post values to SQL server.