0

Based on the response presented in this topic [Writing to MySQL database with pandas using SQLAlchemy, to_sql, how would it be possible, with pandas and fuzzywuzzy, to compare a csv file with the data in the database (in two columns) and if it already exists, overwrite information in two other columns, and if there is no addition of the entire row?

EDIT

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)
Gallaecio
  • 3,620
  • 2
  • 25
  • 64
marcos
  • 1
  • 1

0 Answers0