I am extracting data from google sheet and I have to insert that data frame to MySQL localhost database.
I have tried this, and it doesn't work for me: How to insert pandas dataframe via mysqldb into database?
df.to_sql(con=mydb,schema = 'automate', name='live_nos', if_exists='append', flavor='mysql')
I am getting an error. TypeError: to_sql() got an unexpected keyword argument 'flavor'
When I remove the flavor from this it gives my programming error as follow.
DatabaseError: Execution failed on sql 'SELECT name FROM sqlite_master WHERE type='table' AND name=?;': Not all parameters were used in the SQL statement.
I am using mysql.connector.connect to make the connection :-
mydb = mysql.connector.connect(
host="127.0.0.1",
user="root",
passwd="12345678"
)
This is my data frame which I extract from the google sheet.
Columns :- dates A B C D E
Row to insert :- 5/1/2019 2712 4854 1273 711 345
I want to insert this pandas data frame into MySQL localhost:-
sql = "select * from automate.live_nos"
data = pd.read_sql_query(sql,mydb)
The table in MySQL:-
columns :- dates A B C D E
Pls help