我正在使用sqlite3 python模块,以下代码返回错误
> Exception in Tkinter callback Traceback (most recent call last):
> File "C:\Python34\lib\tkinter\__init__.py", line 1533, in __call__
> return self.func(*args) File "C:\MonitorSoft\MonitorSoft.py", line 199, in LoadSQL
> CurFiles.execute('SELECT * FROM Files WHERE CheckSum = ?', (WinRedactor.Table.item(WinRedactor.Table.selection()[0],
> option='values')[3],))
>
> sqlite3.InterfaceError: Error binding parameter 0 - probably
> unsupported type.
def LoadSQL(event):
con = sqlite3.connect('C:/MonitorSoft/SoftMon.db')
CurPackets = con.cursor()
CurFiles = con.cursor()
CurFilesIn = con.cursor()
curFilesPackets = con.cursor()
CurPackets.execute('SELECT * FROM Packets WHERE PacketName = ?', (WinRedactor.Combobox.get(),))
for RowPackets in CurPackets:
if WinRedactor.Combobox.get() !='NULL':
while WinRedactor.Table.selection() != '':
CurFilesIn.execute('INSERT INTO Files (id, FilePath, FileName, Size, CheckSum) VALUES(NULL, ?, ?, ?, ?)',((WinRedactor.Table.item(WinRedactor.Table.selection()[0], option='values')[0]), (WinRedactor.Table.item(WinRedactor.Table.selection()[0], option='values')[1]), (WinRedactor.Table.item(WinRedactor.Table.selection()[0], option='values')[2]),(WinRedactor.Table.item(WinRedactor.Table.selection()[0], option='values')[3])))
con.commit()
CurFiles.execute('SELECT * FROM Files WHERE CheckSum = ?', (WinRedactor.Table.item(WinRedactor.Table.selection()[0], option='values')[3],))
for RowFiles in CurFiles:
if RowFiles[4] == (WinRedactor.Table.item(WinRedactor.Table.selection()[0], option='values')[3]):
curFilesPackets.execute('INSERT INTO FilesPackets (IDFile, IDPacket) VALUES(?,?)',((RowFiles[0]), (RowPackets[0])))
con.commit()
WinRedactor.Table.delete(WinRedactor.Table.selection()[0])
con.commit()
con.close()
BtnLoadSQL = Button(WinRedactor)
BtnLoadSQL["text"] = "LOAD SQL"
BtnLoadSQL.bind("<Button-1>",LoadSQL)
BtnLoadSQL.pack()
出了什么问题?
在你写的时候结束了数据。 各地的数据都是一样的。 错误在不同的行上随机出现。 以下是您编写输出的示例:
selection is ('I04C', 'I04D', 'I04E', 'I04F', 'I050', 'I051', 'I052', 'I053', 'I054', 'I055', 'I056', 'I057', 'I058', 'I059', 'I05A', 'I05B', 'I05C', 'I05D', 'I05E', 'I05F', 'I060', 'I061', 'I062', 'I063', 'I064', 'I065', 'I066', 'I067', 'I068', 'I069', 'I06A', 'I06B', 'I06C', 'I06D', 'I06E', 'I06F', 'I070', 'I071', 'I072', 'I073', 'I074', 'I075', 'I076', 'I077', 'I078', 'I079', 'I07A', 'I07B', 'I07C', 'I07D', 'I07E', 'I07F', 'I080', 'I081', 'I082', 'I083', 'I084', 'I085', 'I086', 'I087', 'I088', 'I089', 'I08A', 'I08B', 'I08C', 'I08D', 'I08E', 'I08F', 'I090', 'I091', 'I092', 'I093', 'I094', 'I095', 'I096', 'I097', 'I098', 'I099', 'I09A', 'I09B', 'I09C', 'I09D', 'I09E', 'I09F', 'I0A0', 'I0A1', 'I0A2', 'I0A3', 'I0A4', 'I0A5', 'I0A6', 'I0A7', 'I0A8', 'I0A9', 'I0AA', 'I0AB', 'I0AC', 'I0AD', 'I0AE', 'I0AF', 'I0B0', 'I0B1', 'I0B2', 'I0B3', 'I0B4', 'I0B5', 'I0B6', 'I0B7', 'I0B8', 'I0B9', 'I0BA', 'I0BB', 'I0BC', 'I0BD', 'I0BE', 'I0BF', 'I0C0', 'I0C1', 'I0C2', 'I0C3', 'I0C4', 'I0C5', 'I0C6', 'I0C7', 'I0C8', 'I0C9', 'I0CA')
first selection is I04C
values are ('C:\\WINDOWS\\Resources\\Themes\\Luna\\Shell\\Metallic', 'shellstyle.dll', '362496', '05b3f32c7f3bd125446d024a30373c9d')
checksum: 05b3f32c7f3bd125446d024a30373c9d
selection is ('I04D', 'I04E', 'I04F', 'I050', 'I051', 'I052', 'I053', 'I054', 'I055', 'I056', 'I057', 'I058', 'I059', 'I05A', 'I05B', 'I05C', 'I05D', 'I05E', 'I05F', 'I060', 'I061', 'I062', 'I063', 'I064', 'I065', 'I066', 'I067', 'I068', 'I069', 'I06A', 'I06B', 'I06C', 'I06D', 'I06E', 'I06F', 'I070', 'I071', 'I072', 'I073', 'I074', 'I075', 'I076', 'I077', 'I078', 'I079', 'I07A', 'I07B', 'I07C', 'I07D', 'I07E', 'I07F', 'I080', 'I081', 'I082', 'I083', 'I084', 'I085', 'I086', 'I087', 'I088', 'I089', 'I08A', 'I08B', 'I08C', 'I08D', 'I08E', 'I08F', 'I090', 'I091', 'I092', 'I093', 'I094', 'I095', 'I096', 'I097', 'I098', 'I099', 'I09A', 'I09B', 'I09C', 'I09D', 'I09E', 'I09F', 'I0A0', 'I0A1', 'I0A2', 'I0A3', 'I0A4', 'I0A5', 'I0A6', 'I0A7', 'I0A8', 'I0A9', 'I0AA', 'I0AB', 'I0AC', 'I0AD', 'I0AE', 'I0AF', 'I0B0', 'I0B1', 'I0B2', 'I0B3', 'I0B4', 'I0B5', 'I0B6', 'I0B7', 'I0B8', 'I0B9', 'I0BA', 'I0BB', 'I0BC', 'I0BD', 'I0BE', 'I0BF', 'I0C0', 'I0C1', 'I0C2', 'I0C3', 'I0C4', 'I0C5', 'I0C6', 'I0C7', 'I0C8', 'I0C9', 'I0CA')
first selection is I04D
values are ('C:\\WINDOWS\\Resources\\Themes\\Luna\\Shell\\NormalColor', 'shellstyle.dll', '361472', '23ecf1c97b1eb5d94a25dc677ec464e5')
checksum: 23ecf1c97b1eb5d94a25dc677ec464e5
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python34\lib\tkinter\__init__.py", line 1533, in __call__
return self.func(*args)
File "C:\MonitorSoft\MonitorSoft.py", line 213, in LoadSQL
CurFiles.execute('SELECT * FROM Files WHERE CheckSum = ?', (checksum,))
sqlite3.InterfaceError: Error binding parameter 0 - probably unsupported type.
这是最后两个结论,最后,你可以看到有一个错误。
答案 0 :(得分:0)
要解决此问题,第一步应该是打印出所有直接值,这样您就可以验证它们是否符合您的想法。作为副作用,这使您的select语句更容易阅读。
例如:
selection = WinRedactor.Table.selection()
print("selection is", selection)
first_selection = selection[0]
print("first selection is", first_selection)
values = WinRedactor.Table.item(first_selection, option='values')
print("values are", values)
checksum = values[3]
print("checksum:", checksum)
CurFiles.execute('SELECT * FROM Files WHERE CheckSum = ?', (checksum,))
我的猜测是,你会对你看到的内容感到惊讶。至少,您有更多的数据要放入您的问题,以便我们准确地知道数据是什么。