Importing data from a MySQL database into a Pandas data frame including column names [duplicate]
IMO it would be much more efficient to use pandas for reading data from your MySQL server:
from sqlalchemy import create_engineimport pandas as pddb_connection_str = 'mysql+pymysql://mysql_user:mysql_password@mysql_host/mysql_db'db_connection = create_engine(db_connection_str)df = pd.read_sql('SELECT * FROM table_name', con=db_connection)
this should also take care of column names...