Walking through a mysql db
wweston at att.net
Sat Jun 4 15:52:30 CEST 2005
Jeff Elkins wrote:
> I'm writing a small wxpython app to display and update a dataset. So far, I
> get the first record for display:
> cursor = conn.cursor ()
> cursor.execute ("SELECT * FROM dataset")
> item = cursor.fetchone ()
> Now, how do I step through the dataset one row at a time? My form has 'next'
> and 'back' buttons, and I'd like them to step forward or back, fetching the
> appropriate row in the table. I've tried setting cursor.rownumber by
> incrementing it prior to the fetchone() w/o effect.
> Thanks for any pointers.
> Jeff Elkins
You just check for a fetchone return of None. "list" is a list
of tuples here.
cursor.execute( sql )
list = 
row = cursor.fetchone()
if not row:
More information about the Python-list