0
次のコードでMySQL DBをクエリしています。Python:MYSQL列名の大文字と小文字の区別を無視します。
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()
問題はrow['firstName']
で指定した列名が一致していないということで、大文字と小文字が区別されます。大文字と小文字の区別を無視する方法はありますか?