[英]SqlSave Error: Unable to append to table
Code: 码:
sqlSave(SQL,data.frame(df),tablename='Data',append = TRUE,rownames = FALSE)
The table in which I am trying to insert the data has a primary key which is auto-increment. 我要在其中插入数据的表的主键是自动递增的。 My table has a total of 5 columns including the primary key.
我的表共有5列,包括主键。 In my data frame, I have 4 columns because I don't want to insert the PK myself.
在我的数据框中,我有4列,因为我不想自己插入PK。 However, when I run the command, I get the following error:
但是,当我运行命令时,出现以下错误:
Error in colnames<-
( *tmp*
, value = c("BId", "name", "Set", : length of 'dimnames' [2] not equal to array extent colnames<-
错误colnames<-
( *tmp*
,value = c(“ BId”,“ name”,“ Set”,:'dimnames'[2]的长度不等于数组范围
Also, when I insert the Primary key in the dataframe by myself, it still doesn't work. 另外,当我自己将主键插入数据框中时,它仍然不起作用。
Error in sqlSave(SQL, data.frame(df), tablename = "Data", : unable to append to table 'Data' sqlSave(SQL,data.frame(df),tablename =“ Data”,错误:无法追加到表'Data'
have a try safer = FALSE
尝试
safer = FALSE
the defination of sqlSave sqlSave的定义
if (!append) {
if (safer)
stop("table ", sQuote(tablename), " already exists")
......
}
......
if (safer)
stop("unable to append to table ", sQuote(tablename))
您可以使用use verbose参数获取实际的数据库错误。
sqlsave(con, df, verbose = T)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.