[R] sqlsave and mysql database with autoincremental column

PtitBleu ptit_bleu at yahoo.fr
Tue Feb 1 14:47:17 CET 2011


Hello,

I'm trying to modify my r-script to use RODBC instead of DBI/RMySQL (no more
ready-to-use package for windows).

I would like to copy a data.frame of 44 columns to a table of 45 columns
(the 45th is an autoincremental column).

With the following commands, 

colnames(df)<- a vector with the names of the 44 columns
ch<-odbcDriverConnect(connection="SERVER=localhost;DRIVER=MySQL ODBC 5.1
Driver;DATABASE=my_db;UID=usercount;PWD=my_pwd;case=tolower")
sqlSave(ch,my_df, "my_table", append = TRUE, rownames = FALSE, fast=FALSE)
odbcClose(ch)

I got the following message (in french, sorry): 
Erreur dans dimnames(x) <- dn :  la longueur de 'dimnames' [2] n'est pas
égale à l'étendue du tableau
It means something like: the length of 'dimnames' [2] is not equal to the
array extent

If I do the same with a table with only 44 columns, without the
autoincremental column, it works ... but I need this last column.

Could you please help me to modify my commands so that I can copy 44-columns
data.frame to the 45-columns MySQL table ?

Thanks in advance,
Ptit Bleu.





-- 
View this message in context: http://r.789695.n4.nabble.com/sqlsave-and-mysql-database-with-autoincremental-column-tp3251425p3251425.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list