Originally Posted by
OlleEriksson
Do you experience the same problems with other frontends? It's not impossible that something's wrong with the database.
Well i havent really tried any other front ends tba. I wrote this Python script to demonstrate how you can use the same script in linux, windows and mac, and it does just that.
The database is just a standard install of Mysql for ubuntu 7.04 and only has a very small table in it with three records in it.
It takes about ten seconds to retrieve those three records when it runs on either windowz or llinux, (i havent got a mac to test it on)
here's my python program to look at:
Code:
import wx
import MySQLdb
ID_ABOUT = 101
ID_EXIT = 110
ID_LOGIN = 111
class MainWindow(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, wx.ID_ANY, title, size = (400, 200),
style = wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_RESIZE )
self.control = wx.TextCtrl( self, 1, style = wx.TE_MULTILINE )
self.CreateStatusBar()
filemenu = wx.Menu()
filemenu.Append(ID_LOGIN, "L&ogin", "Login to the Mysql DB")
filemenu.AppendSeparator()
filemenu.Append(ID_ABOUT, "&About", "About this program")
filemenu.AppendSeparator()
filemenu.Append(ID_EXIT, "E&xit", "Exit this program")
menubar = wx.MenuBar()
menubar.Append(filemenu, "F&ile")
# link up events to menu selections
wx.EVT_MENU(self, ID_LOGIN, self.OnLogin)
wx.EVT_MENU(self, ID_ABOUT, self.OnAbout)
wx.EVT_MENU(self, ID_EXIT, self.OnExit)
self.SetMenuBar(menubar)
self.Show(True)
def OnAbout(self, event):
d = wx.MessageDialog(self, "A simple Database Connector", "About DB Connector", wx.OK)
d.ShowModal()
d.Destroy()
def OnExit(self, event):
self.Close(True)
def OnLogin(self, event):
# logiin to a mysql db
db = MySQLdb.connect(host='10.10.3.179', user='myUID', passwd='MyPWD',db='MyDBName')
cursor = db.cursor()
cursor.execute('SELECT * FROM tblUsers')
result = cursor.fetchall()
for record in result:
self.control.AppendText(record[1])
self.control.AppendText(" ")
self.control.AppendText(record[2])
self.control.AppendText("\n")
app = wx.PySimpleApp()
frame = MainWindow(None, -1, "Network Database Test")
app.MainLoop()
Mike
Bookmarks