Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import gtk
- import MySQLdb as mdb
- import sys
- def send_press(widget):
- try:
- con = mdb.connect('localhost', 'root', 'root', 'test');
- cur = con.cursor()
- cur.execute("INSERT INTO table1(name) VALUES('" + entry.get_text() + "')")
- cur.execute("SELECT * FROM table1")
- rows = cur.fetchall()
- for row in rows:
- print row
- except mdb.Error, e:
- print "Error %d: %s" % (e.args[0],e.args[1])
- sys.exit(1)
- finally:
- if con:
- con.close()
- win=gtk.Window()
- win.connect('destroy', lambda w: gtk.main_quit())
- box = gtk.VBox()
- win.add(box)
- entry=gtk.Entry()
- box.pack_start(entry)
- send=gtk.Button("SEND")
- send.connect("clicked", send_press)
- box.pack_start(send)
- win.show_all()
- gtk.main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement