From: Ashley E. <as...@si...> - 2006-06-15 22:26:18
|
Hi all I am new to python and just getting to grips with it, although i have many years experience with PHP anyway, my question is, I want to create a small script, or later an exe that shows the MySQL db processes with SHOW PROCESSLIST in the style of linux 'top' app which refreshes the display every x seconds, initially, i want to display this process list in a 'DOS' or shell type window, or run directly from DOS or the command prompt. now, ive created a feww lines of code that fetch the rows from the db and print out a simple list of columns (in tuples?) import MySQLdb db = MySQLdb.connect(host="10.0.0.3",user="root",passwd="",db="mysql") cursor = db.cursor() cursor.execute("SHOW PROCESSLIST") res = cursor.fetchall() for row in result: print row cursor.close() db.close() i just need to know how to turn this isto a looping affair, which refrshes the display, rather than kicking out the info every time and information on how to achieve this so my questions are: are there any libs i need which i can import into my script to make this easier, i already have wxpython and pythonCard installed? would i be able to put this code inside a function and loop the function somehow: def ShowProc(): cursor.execute("SHOW PROCESSLIST") res = cursor.fetchall() for row in result: print row # some code here to refresh the display eg while True: ShowProc() i eventually want to create a GUI that does all this for me so i can run the small app on my desktop while working, to keep an eye on the db servers i have to manage but im happy to just get this running command line for now as its the first thing ive tried in python finally, am i even on the right track with this?? kind regards Ash ----- Original Message ----- From: "Andy Todd" <an...@ha...> To: "Lance Haig" <lh...@ha...> Cc: "PythonCard" <pyt...@li...> Sent: Thursday, June 15, 2006 10:23 PM Subject: Re: [Pythoncard-users] What Project is a good one to start on? > Lance Haig wrote: >> Any ideas for a newbie? >> >> Just looking for something that will help grow my skills. >> >> Thanks >> >> Lance >> >> -- >> *Lance Haig* >> Director >> > [snip] > > The usual answer is to scratch your own itch. If you're looking to > improve your knowledge and ability with PythonCard then I'd suggest > starting with a small application that helps you out. For me it was an > address book (which I'm not releasing because it wasn't very good) and > then I moved on to a database query tool which became the dbBrowser > sample. > > If you're building something that you want and/or need then it becomes > much more than a learning exercise and you'll be better for the > experience. > > Regards, > Andy > -- > -------------------------------------------------------------------------------- > From the desk of Andrew J Todd esq - http://www.halfcooked.com/ > > > _______________________________________________ > Pythoncard-users mailing list > Pyt...@li... > https://lists.sourceforge.net/lists/listinfo/pythoncard-users > > > > > -- > No virus found in this incoming message. > Checked by AVG Free Edition. > Version: 7.1.394 / Virus Database: 268.8.4/364 - Release Date: 14/06/2006 > > |