I get the following when appending boolean data to an existing table.
> dbWriteTable(conn, "myTable", myData, overwrite = F, append = T, csvdump = T)
Error in .local(conn, statement, ...) : Unable to execute statement 'COPY 1292 RECORDS INTO myTable FROM 'C:\\Path\\to\\AppData\\Local\\Temp\\Rtmp80mc5L\\file3e24401f42a.cs...'.
Server says '!value 'TRUE' from line 1 field 20 not inserted, expecting type boolean'.
I've taken some code of the connector which deals with this:
> tmp <- tempfile(fileext = ".csv")
> write.table(myData, tmp, sep = ",", quote = TRUE,row.names = FALSE, col.names = FALSE,na="")
> tmp
[1] "C:\\Path\\to\\AppData\\Local\\Temp\\Rtmp80mc5L\\file3e24401f42a.csv"
When changing TRUE to 1 and FALSE to 0 and run the following SQL code:
COPY 1292 RECORDS INTO myTable FROM 'C:\\Path\\to\\AppData\\Local\\Temp\\Rtmp80mc5L\\file3e24401f42a.csv' USING DELIMITERS ',','\\n','"' NULL AS '' LOCKED;
then all data is inserted.
There seems to be some need for conversion of boolean columns. In the meantime, does it work with csvdump=F?
CREATE TABLE TABLE1 (
INFO VARCHAR(5),
SECURE BOOLEAN
);
CREATE TABLE TABLE2 (
INFO VARCHAR(5),
SECURE BOOLEAN
);
insert into TABLE1 (INFO, SECURE) values ('FALSE',FALSE);
insert into TABLE1 (INFO, SECURE) values ('TRUE',TRUE);
> library(MonetDB.R)
> conn <- dbConnect(MonetDB.R(), "monetdb://localhost/demo")
> myData <- dbGetQuery(conn,"select * from table1")
> dput(myData)
structure(list(info = c("FALSE", "TRUE"), secure = c(FALSE, TRUE )), .Names = c("info", "secure"), row.names = c(NA, 2L), class = "data.frame")
> dbWriteTable(conn, "table2", myData, overwrite = F, append = T, csvdump = F)
[1] TRUE
> dbWriteTable(conn, "table2", myData, overwrite = F, append = T, csvdump = T)
Error in .local(conn, statement, ...) : Unable to execute statement 'COPY 2 RECORDS INTO table2 FROM 'C:\\Path\\to\\AppData\\Local\\Temp\\Rtmp80mc5L\\file3e241533d14.csv' US...'.
Server says '!value 'FALSE' from line 3 field 2 not inserted, expecting type boolean'.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.