Greetings, I have problems with the insertion of new records to a Database.
I use the library RODBC
to connect to the database from R, all right there, but when I want to add a record that I have stored in a data frame like:
datos<- data.frame(nombre="juan",edad=22)
sqlSave(canal,tablename="alumnos",datos,append=TRUE)
I get an error, what can I do? Do you have any suggestions? I am looking forward to your response. Thank you very much.
Update:
My code is simple:
library(RODBC)
canal <- odbcConnect("PrMYSQL",uid = "root")
datos<-data.frame(nombre='alberto', edad=31,sexo= 'masculino')
guardar<- sqlQuery(canal,"INSERT INTO alumnos (nombre,edad,sexo) VALUES (",paste(datos[1,]),")")
When executing I get the following error:
Error in if (errors) return(odbcGetErrMsg(channel)) else
return(invisible(stat)) : argument is not interpretable as logical
I hope you can help me thanks