[英]Error with python orm peewee
I love using python orm peewee, but I getting this error again and again. 我喜欢使用python orm peewee,但是却一次又一次出现此错误。
"InterfaceError: Error binding parameter 0 - probably unsupported type" “ InterfaceError:错误绑定参数0-可能不受支持的类型”
The most frustrating thing is that it does not shows always. 最令人沮丧的是,它并不总是显示。 It appears to act arbitrarily. 它似乎是任意行动。
The code that causes the error is quite simple and as I said, sometimes works sometimes does not. 导致该错误的代码非常简单,正如我所说,有时有效,有时却无效。
lista=Tareas.select().where((Tareas.ta_usuario==self.user.id) & (Tareas.done=="True"))
for tarea in lista:
borrada=tarea.delete_instance()
Any clue about what can be causing the error? 关于什么可能导致错误的任何线索?
The difinition of tareas is simple: tareas的定义很简单:
class Tareas(SqliteModel):
task = CharField()
done = CharField()
ta_usuario = IntegerField()
This is issue #81 . 这是问题#81 。 The problem is that you are modifying the data while consuming the loop. 问题是您在使用循环时正在修改数据。
Try this: 尝试这个:
lista = Tareas.select().where(
(Tareas.ta_usuario==self.user.id) & (Tareas.done=="True")
)
lista_de_tareas = [i for i in lista]
for tarea in lista_de_tareas:
borrada = tarea.delete_instance()
See the response to the GitHub issue for other solutions. 有关其他解决方案,请参见对GitHub问题的回复。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.