I am exporting a dataframe from R to MySQL with the following command
sqlSave(con1,test_data, "prices",safer=FALSE,rownames=TRUE,addPK=TRUE)
My dataframe has four columns with numeric data (stock prices) and the date column is the row names. Now when I export this to MySQl all is fine. However, when in MySQL I rename the rownames as follows:
ALTER TABLE `test`.`prices`
CHANGE COLUMN `rownames` `date` DATE NULL DEFAULT NULL;
I obtain the following error when I want to save the updated version of the data
Error in odbcUpdate(channel, query, mydata, coldata[m, ], test = test, :
missing columns in »data«
For replication here is a snapshot of my dataframe
row.names A B C D
1987-12-31 247.08 NA 648.13 21564.00
1988-01-29 257.07 NA 635.95 23622.32
1988-02-29 267.82 NA 708.88 25242.81
1988-03-31 258.89 NA 701.56 26260.26
1988-04-29 261.33 NA 710.55 27434.12
What is the problem and how can I solve this?