I\'m not asking for the SHOW COLUMNS command.
I want to create an application that works similarly to heidisql, where you can specify an SQL query and w
Similar to @James answer, a more pythonic way can be:
fields = map(lambda x:x[0], cursor.description)
result = [dict(zip(fields,row)) for row in cursor.fetchall()]
You can get a single column with map over the result:
extensions = map(lambda x: x['ext'], result)
or filter results:
filter(lambda x: x['filesize'] > 1024 and x['filesize'] < 4096, result)
or accumulate values for filtered columns:
totalTxtSize = reduce(
lambda x,y: x+y,
filter(lambda x: x['ext'].lower() == 'txt', result)
)