我想用Pandas的to_sql函数创建一个MySQL表,它有一个主键(在mysql表中有一个主键通常很好),如下所示:
group_export.to_sql(con = db, name = config.table_group_export, if_exists = 'replace', flavor = 'mysql', index = False)
Run Code Online (Sandbox Code Playgroud)
但这会创建一个没有任何主键的表(甚至没有任何索引).
文档提到参数'index_label'与'index'参数结合使用可用于创建索引但不提及主键的任何选项.