supongo que es problema con el fetchall()
codigo
Código Python:
Ver original
import wx import sqlite3 as lite class InsertarDato(wx.Frame): def __init__(self, parent, id, title): self.con = lite.connect("MiBase.sqlite") self.cur = self.con.cursor() wx.Frame.__init__(self, parent, id, title, size = (280, 200)) panel = wx.Panel(self, -1) gs = wx.FlexGridSizer(3, 2, 9, 9) vbox = wx.BoxSizer(wx.VERTICAL) hbox = wx.BoxSizer(wx.HORIZONTAL) codigo = wx.StaticText(panel, -1, "Codigo") producto = wx.StaticText(panel, -1, "Producto") costo = wx.StaticText(panel, -1, "Costo") self.sp = wx.TextCtrl(panel, -1, "", size = (60, -1)) self.tc1 = wx.TextCtrl(panel, -1, size = (150, -1)) self.tc2 = wx.TextCtrl(panel, -1, size = (150, -1)) gs.AddMany([(codigo), (self.tc1, 1, wx.LEFT, 10), (producto), (self.tc2, 1, wx.LEFT, 10), (costo), (self.sp, 0, wx.LEFT, 10)]) vbox.Add(gs, 0, wx.ALL, 10) vbox.Add((-1, 30)) guardar = wx.Button(panel, -1, "Guardar", size = (-1, 30)) salir = wx.Button(panel, -1, "Salir", size = (-1, 30)) buscar = wx.Button(panel, -1, "Buscar", size = (-1, 30)) hbox.Add(guardar) hbox.Add(salir, 0, wx.LEFT, 5) hbox.Add(buscar, 0, wx.RIGHT, 5) vbox.Add(hbox, 0, wx.ALIGN_CENTER | wx.BOTTOM, 10) self.Bind(wx.EVT_BUTTON, self.OnGuardar, id = guardar.GetId()) self.Bind(wx.EVT_BUTTON, self.OnSalir, id = salir.GetId()) self.Bind(wx.EVT_BUTTON, self.OnBuscar, id = buscar.GetId()) panel.SetSizer(vbox) self.Centre() self.Show(True) def OnGuardar(self, event): try: codigo = self.tc1.GetValue() producto = self.tc2.GetValue() costo = self.sp.GetValue() self.cur.execute("insert into inventario values (?, ?, ?)", (codigo, producto, costo)) self.con.commit() self.tc1.Clear() self.sp.Clear() self.tc2.Clear() except lite.Error, error: dlg = wx.MessageDialog(self, str(error), "Ha ocurrido un error") dlg.ShowModal() def OnSalir(self, event): self.Destroy() def OnBuscar(self, event): self.tc1.GetValue() self.cur.execute("SELECT * FROM inventario WHERE codigo = %s" %self.tc1.GetValue()) self.tc1.Clear() self.recs_list = self.cur.fetchall() print self.recs_list app = wx.App() InsertarDato(None, -1, "Dialogo de Inventario") app.MainLoop()