Is there a way to retrieve SQL result column value using column name instead of column index in Python? I\'m using Python 3 with mySQL. The syntax I\'m looking for is pretty
import mysql
import mysql.connector
db = mysql.connector.connect(
host = "localhost",
user = "root",
passwd = "P@ssword1",
database = "appbase"
)
cursor = db.cursor(dictionary=True)
sql = "select Id, Email from appuser limit 0,1"
cursor.execute(sql)
result = cursor.fetchone()
print(result)
# output => {'Id': 1, 'Email': 'me@gmail.com'}
print(result["Id"])
# output => 1
print(result["Email"])
# output => me@gmail.com