0
我用下面的代碼查詢我的MySQL數據庫。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']
指定的列名不匹配,並且區分大小寫。有沒有辦法忽略區分大小寫?