Python Forum

Full Version: MySql and field names.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi folks, I'm a programmer of many, many years, but not with Python, so I'm very new to the way of thinking and the syntax.

At the moment I'm struggling to find a way to work with the field 'names' of database queries. I can find forum posts where people return field names for printing, but that's no use, I need to be able to use them.

I have a data set in a cursor, it runs a fetch many(x), then a for row loop.

I need to run sql commands on the data in each row. Because of the complexity to he calculations, updating the rows and other database tables is impractical using one single update statement.

So I want to loop the cursor.rows with something like
"Update trees set Height=1.354, Mass=4.2437563 Where TreeName=", row[TreeName]

With the standard cursor I have to use [0], [1], [2] etc for field reference, this is crap!

(And yes, I'll need a second cursor/connection but that's a price I'm prepared to pay)

All help would be appreciated.
Thanks.
Many thanks bran, I will give these a good read through. Cheers.