Python: Ignore case sensitivity for MYSQL column names
Question: I am querying my MySQL DB with following code.

    
    
    import MySQLdb
    
    db = MySQLdb.connect("localhost","user","password","test" )
    cursor = db.cursor(MySQLdb.cursors.DictCursor)
    sql = "select * from student"
    try:
        cursor.execute(sql)
        results = cursor.fetchall()
        for row in results:
            print row['firstname']
    except:
        print "Error: unable to fecth data"
    db.close()
    

Problem is that the column name specified in `row['firstName']` does not match
and is case sensitive. Is there any way to ignore case sensitivity?


Answer: you can use this:

    
    
    sequence = cursor.column_names
    

<https://dev.mysql.com/doc/connector-python/en/connector-python-api-
mysqlcursor-column-names.html>

Then compare your string to the actual name with .lower() and act accordingly

