python - pyodbc.ProgrammingError: ('无效的参数类型。param-index=1 param-type=StringVar', 'HY105')
问题描述
我正在尝试使用 Python 将一些数据插入 DB2。我有一个 GUI 表单(TKINTER)来从用户那里获取数据,所以在每个条目中我需要分配一个变量,所以这里有一个例子:
comment = StringVar()
comment_label = Label(text="Comment:", font=("Arial", 12))
comment_label.place(x=20, y=150)
comment_entry = Entry(textvariable=comment, width="110", font=("Arial", 12))
comment_entry.place(x=120, y=150)
但是当我尝试插入这个变量时,我得到了这个错误:
pyodbc.ProgrammingError: ('Invalid parameter type. param-index=1 param-type=StringVar', 'HY105')
顺便说一句,这是插入代码:
registrar_intervencion_cursor = conn_db2.cursor()
registrar_intervencion_query = "INSERT INTO BIUMO220.TICKREGINTERVENCION(numerador, responsable, fecha, centro, tipo_intervencion, subtipo, comentario, ref_producto_final, df_producto_final, ref_componente, df_componente, util, df_util, tiempo_intervencion) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
registrar_intervencion_cursor.execute(registrar_intervencion_query, numerador, responsable, fecha_hoy, resultado_centro, resultado_intervencion, resultado_subtipo_intervencion, comentario, ref_producto_final, res, ref_componente, componente_row, util, util_row, tiempo_aprox_intervencion)
registrar_intervencion_cursor.commit()
是的,这是一个很大的表格,有很多变量。
解决方案
推荐阅读
- angular - Angular 8和组件之间的路由而不会丢失状态
- python - python请求给
- angular - ngrx 8:来自 reducer 函数的 @ngrx/data 实体的访问状态
- python-3.x - 如何更改字符串的特定部分?
- javascript - 选择 6 个下拉选项之一时 Javascript 隐藏字段
- bluetooth - 蓝牙经典 5.1?
- c++ - 将一个类的对象放入另一个类的数组中
- c++ - 如何获得 BITMAPFILEHEADER 和 BITMAPINFOHEADER 的字节表示?
- string - Bash:如何计算文件中字符串的出现次数?
- python - 调试“ImportError:尝试使用没有已知父包的相对导入”