RODBC sqlSave () and mapping column names

I have a question about using sqlSave. How does R map RODBC data in a data frame to columns of a database table?

If I have a table with columns X and Y and a data frame with columns X and Y, RODBC puts X in X and Y in Y (I found out by trail-and-error). But can I explicitly tell R how to map the data.frame columns to the columns of the database table, for example, put A in X and B in Y.

I'm new to R and I think the RODBC leadership is a bit cryptic. I also can not find an example on the Internet.

+3
source share
3 answers

Now I do it like this (maybe this is what you had in mind):

colnames(dat) <- c("A", "B")
sqlSave(channel, dat, tablename = "tblTest", rownames=FALSE, append=TRUE)

This works for me. Thank you for your help.

+2
source

R, , R, .

  help(sqlSave)

colNames. c("A", "B") data.frame A ..

+1

I am having serious problems using the sqlSaveIBM DB2 database. I am trying to avoid this, using sqlQueryinstead to create a table with the correct formatting, and then use sqlSaveusing append=Tto force the table R into the database table. This solves a lot of problems, such as date and floating point formats (instead of two local ones).

+1
source

Source: https://habr.com/ru/post/1740325/


All Articles