根据本主题[Writing to MySQL database with pandas using SQLAlchemy, to_sql中的回答,如何使用pandas和Fuzzywuzzy将csv文件与数据库中的数据进行比较(分为两列),以及是否已经存在,覆盖其他两列中的信息,以及是否没有添加整行?
编辑
import pandas as pd
from sqlalchemy import create_engine
column_names = ['column1', 'column2', 'column3', 'column3', 'column4', 'column5']
df = pd.read_csv('file.csv', header = None, names = column_names)
print(df)
engine = create_engine('mysql+pymysql://user:password@localhost')
with engine.connect() as conn, conn.begin():
df.to_sql('tableminysql', conn, if_exists='replace', index=False)