When running cursor_insert.execute(sql,params), I keep getting "[SQL ERROR] Error converting data type nvarchar to float" even though my source and target db table have the data defined as float, nvarchar and nvarchar along with my stored procedure.
Is setting my parameters to a new variable called 'params' causing this change in datatype? If so, how can I work around it? (In reading some Python documentation, it shouldn't have changed the datatype, correct?)
# Create cursor associated with connection
cursor=conn.cursor()
cursor_select = conn.cursor()
cursor_insert = conn.cursor()
if conn:
print('***** Connected to DCPWDBS289 *****')
select_str="SELECT TOP 5 Incident_ID,Incident_Type,Priority FROM
incidents_all WHERE incidents_all.Status NOT IN ('Closed','Resolved')"
cursor_select.execute(select_str)
while True:
row = cursor_select.fetchone()
if not row:
break
print(' Row: ', row)
IncIncident_ID = row[0] # Float
IncIncident_Type = row[1] # Str
IncPriority = row[2] # Str
sql = """EXEC ITSM.dbo.ITSM_LOAD @IncIncident_ID=?,
@IncIncident_Type=?,@IncPriority=?"""
params = ('IncIncident_ID','IncIncident_Type','IncPriority')
cursor_insert.execute(sql,params)
del cursor_insert
cursor.commit()
conn.close()