dimanche 20 mars 2016

total tracking varible using sqlite fetchone

I am, having problems trying to sore the output of an sqlite query in a python variable to keep track of a total. I have looked around and seen examples using the c.fetchone() method but I cannot seem to get it to work , I keep getting the error TypeError: 'NoneType' object has no attribute '___getitem____' . I don't understand what this means . can anyone help?

    i = -1
    i = i + 1

    self.t = pytesseract.image_to_string(PIL.Image.open('test2.jpg'))
    self.c.execute("SELECT name FROM item WHERE code = '%s'" % self.t)
    self.listbox.insert(i,self.c.fetchone())
    self.listbox1.insert(i,"£")
    self.c.execute("SELECT price FROM item WHERE code = '%s'" % self.t)
    self.listbox2.insert(i,self.c.fetchone())

    self.y=self.c.fetchone()[i]
    print self.y

Aucun commentaire:

Enregistrer un commentaire