Unknown column in field list error Rmysql

天大地大妈咪最大 提交于 2019-12-10 22:19:10

问题


I wrote a data.frame using

dbWriteTable(con, name='db_all', df, overwrite=T, row.names=F) 

sucessfully to MySQL using RMySQL. Now I have a second data frame which has a similar structure and try to use

dbWriteTable(con,name='db_all',df1,append=T,row.names=F,overwrite=F)

which gives me

Error in .local(conn, statement, ...) : could not run statement: Unknown column 'zzz' in 'field list'>

In my SQL table I don't have that column name yet and would expect my append=T will add this column in my SQL table, which apparently it does not.


回答1:


The append will append data to the table, will not do an alter table adding columns.

You need to specify your columns if the name is not the same as in the dataframe using a named list e.g: field.types=list(dte="date", val="double(20,10)")




回答2:


What is the name of the unknown column? If it is "row_names" then you need to set the parameter row.names = FALSE in dbWriteTable(). Otherwise, it tries to include the row names in your data frame in the insert statement.



来源:https://stackoverflow.com/questions/37644420/unknown-column-in-field-list-error-rmysql

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!