defdf2_mysql(df_data, table_name, **kwargs): """ To wrap a function that insert DataFrame to Mysql :param df_data: DataFrame data :param table_name: The name of mysql table, type is string :param kwargs: The connection of database, type is dict """ engine = sqlalchemy.create_engine( 'mysql+pymysql://{}:{}@{}:{}/{}?charset={}'.format(kwargs['user'], kwargs['password'], kwargs['host'], kwargs['port'], kwargs['db'], kwargs['charset'])) pandas.io.sql.to_sql(df_data, table_name, engine, index=False, if_exists='append', chunksize=10000) # if_exists: 'replace', 'append' engine.dispose()