Hi I am using R to save a data frame to a DB2 SQL table. It seems I can create a table skeleton but not add data to the table -
>df <- read.csv("dat.csv")
where dat.csv is csv without headers, only raw data in two columns
then i create a table:
>sqlQuery(channel, "create table sqltable ( col1 int, col2 float )" (
where I confirm that the table is created by being able to select the empty "sqltable" table in the database
so now I need to add data from "dat.csv" to "sqltable" by doing:
>sqlSave(channel, df, "sqltable", verbose=T, fast=T, append=T) no: 1 rownames 1no: 2 col1 31105no: 3 col2 0.001 no: 2 rownames 1no: 2 col1 31106no: 3 col2 0.023 no: 3 rownames 1no: 2 col1 31107no: 3 col2 1.456 no: 4 rownames 1no: 2 col1 31108no: 3 col2 0.001 no: 5 rownames 1no: 2 col1 31109no: 3 col2 2.102
everything seems good until i do:
>sqlQuery(channel,"select * from sqltable") [1] COL1 COL2 <0 rows> or 0-length row.names
sqlSave command clearly takes data from dat.csv, so why is it not added to the table? what am I doing wrong?
source share