Walking through a mysql db

Jeff Elkins jeffelkins at earthlink.net
Sat Jun 4 11:23:47 EDT 2005


On Saturday 04 June 2005 09:24 am, 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:
>
>  try:
>       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 the responses!  The buttons are working now.

Within this same app, I've got a search function working, but I need the 
rownumber when a record is fetched.

  sql = """select * from address where %s = %%s""" % arg1.lower()
            cursor.execute(sql, (arg2,))
             item = cursor.fetchone ()
             index = cursor.rownumber

At this point, the record is on the screen, but cursor.rownumber doesn't 
reflect the actual rownumber...it always returns 1. How can I obtain the 
actual row number for the displayed record?

Jeff





More information about the Python-list mailing list