运行光标时_插入.执行(sql,params),我不断得到“[sql ERROR]ERROR converting data type nvarchar to float”,即使我的源和目标db表将数据与存储过程一起定义为float、nvarchar和nvarchar。你知道吗
是否将我的参数设置为一个名为“params”的新变量导致了数据类型的更改?如果是的话,我该怎么解决呢?(在阅读一些Python文档时,它不应该更改数据类型,对吗?)你知道吗
# 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()
您不是在传递
parameter
值,而是在传递字符串文本,请尝试以下操作:相关问题 更多 >
编程相关推荐