Python - sqlite problem with python

 
Vista:

sqlite problem with python

Publicado por Juan (2 intervenciones) el 05/06/2012 01:26:00
hey any of you guys could help me?? i have a problem with a script Im making for school, im trying to update a table dependeing if a word was spelled right or wrong, the code tu spellcheck works fine its just that the value on the table does not get updated :/
this is the code hope someone can help me
def wordspell(self):

d = enchant.Dict("en_US")
palabras = self.con.execute(' select rowid, word from wordlist').fetchall()
for row in palabras:
check = d.check(row[1])
if check :
print "true "+str(row[0])
self.con.execute("UPDATE wordlist SET error=? WHERE rowid=?",('no',row[0]))
else:
print "false "+str(row[0])
self.con.execute("UPDATE wordlist SET error=? WHERE rowid=?",('si',row[0]))
it does print whether the word is correct or not the value on the db never gets updated :/
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de xve
Val: 2.239
Plata
Ha mantenido su posición en Python (en relación al último mes)
Gráfica de Python

sqlite problem with python

Publicado por xve (1646 intervenciones) el 05/06/2012 07:51:56
Creo que el problema lo tienes en las consultas SQL de actualización:

Prueba así:
1
self.con.execute("UPDATE wordlist SET error='%s' WHERE rowid=%s" % ('no',row[0]))


Coméntanos, ok?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

sqlite problem with python

Publicado por Juan (2 intervenciones) el 05/06/2012 15:19:05
gracias de hecho encontre el error, soy nuevo en pythoon pero era que me faltaba la sentencia self.con.commit() despues de la consulta sql, muchas gracias.!
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar