Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
MySql Cursor field names.
HI folks.

I've seen this somewhere, but I can't find it...

I can:
cursor.execute("blah and pharp...
for row in cursor:
print row[0]
print row[1]

but how do I get to use the field names? I think it's something to do with a dictionary?

print row{'field1']
print row['field2']

Probably. I think you can use whatever aliases you're using in the query as dict keys. When in doubt, inspect!
for row in cursor:

Possibly Related Threads…
Thread Author Replies Views Last Post
  Cursor Variable inside Another Cursor . CX_ORacle paulo79 1 655 Apr-09-2022, 10:24 AM
Last Post: ibreeden
  Cursor write 3rd file empty paulo79 3 985 Mar-10-2022, 02:51 PM
Last Post: DeaD_EyE
  Mysql error message: Lost connection to MySQL server during query tomtom 6 4,970 Feb-09-2022, 09:55 AM
Last Post: ibreeden
  change mouse cursor (in Windows) mgroen 0 1,053 Nov-11-2020, 11:26 AM
Last Post: mgroen
  Bug ? when dataclass field name == field type Cyril 0 1,084 Oct-22-2020, 03:26 AM
Last Post: Cyril
  How to avoid slow cursor operations? sevensixtwo 0 1,359 Oct-11-2019, 02:23 PM
Last Post: sevensixtwo
  Trouble retrieving dictionary from mysql.connector cursor swechsler 2 2,164 Sep-17-2019, 05:21 PM
Last Post: swechsler
  Best way to return Cursor Data rajuarien 0 1,534 Jul-29-2018, 09:47 PM
Last Post: rajuarien
  Python - Netezza cursor function help leojosefm 4 3,834 Jan-08-2018, 12:03 PM
Last Post: leojosefm
  MySql and field names. MuntyScruntfundle 2 2,176 Dec-01-2017, 12:44 PM
Last Post: MuntyScruntfundle

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020