RMySQL dbWriteTable with field.types

后端 未结 2 1222
野的像风
野的像风 2020-12-01 10:38

I have a data frame, called df, that looks like this:

dte, val
2012-01-01, 23.2323
2012-01-02, 34.343

The type on the columns

2条回答
  •  情话喂你
    2020-12-01 11:14

    After playing with things, I realized what the problem is: field.types must be a NAMED list vector, not simply a list; additionally the row names must not be included otherwise we need three field types. For the above example, the following works fine:

    dbWriteTable(con, name="table_name", value=df,
      field.types = c(dte="date", val="double(20,10)"), row.names=FALSE)
    

提交回复
热议问题