Foros del Web » Programando para Internet » Python »

No inserta datos MySql y python

Estas en el tema de No inserta datos MySql y python en el foro de Python en Foros del Web. Prepare un script en python para grabar en una tabla en Mysql, que me reporta lo q grabo pero al consultarlo en la linea de ...
  #1 (permalink)  
Antiguo 03/09/2007, 13:39
 
Fecha de Ingreso: agosto-2007
Mensajes: 1
Antigüedad: 16 años, 8 meses
Puntos: 0
No inserta datos MySql y python

Prepare un script en python para grabar en una tabla en Mysql, que me reporta lo q grabo pero al consultarlo en la linea de comando de mysql dice q esta vacia la tabla y tambien me informa q esta vacia cuando corro otro script que lee lo q grabe, instale: Python 2.5.1, Wxpython 2.8.4.2_y_p25, Mysql 5.1, Mysql -python1.2.2win32_py2.5
que me falto? anexo el script.

import wx
import MySQLdb

from wxPython.wx import *

class CreaTablaFoliosClientes(wx.Frame):

def __init__(self, parent, id, title,
pos=wx.DefaultPosition,
size=wx.DefaultSize,
style=wx.DEFAULT_FRAME_STYLE):

wx.Frame.__init__(self, parent, id, title, pos, size, style)
coleti=wx.Colour(234,255,244)
coltip=wx.Colour(255,239,191)

conn = MySQLdb.connect ( host = "localhost",
user = "root",
passwd = "toolsoft",
db = "puntodeventa")

cursor = conn.cursor ()

cursor.execute ("SELECT VERSION()")
row = cursor.fetchone ()
print "server version:", row[0]

cursor.execute ("DROP TABLE IF EXISTS tablas")
print "borre tablas"

cursor.execute ("CREATE TABLE tablas ( nom CHAR(15),val CHAR(20) ) ")
print "cree tablas"

cursor.execute ("INSERT INTO tablas (nom, val) VALUES ('foliosotro', '1')")
print "inserte foliosotros"

while (1):
row = cursor.fetchone ()
if row == None:
break
print "%s, %s" % (row[0], row[1])

print "Number of rows returned: %d" % cursor.rowcount

cursor.close ()
conn.close ()

class Miaplicacion(wx.App):
def OnInit(self):
f = CreaTablaFoliosClientes(None, -1, "Probando CreaTablaFoliosClientes")
f.SetBackgroundColour(wxColour(245, 241, 223))
f.Show()
return True

app = Miaplicacion()
app.MainLoop()
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 07:24.