RSQLite
                                
                                 RSQLite copied to clipboard
                                
                                    RSQLite copied to clipboard
                            
                            
                            
                        feature request: allow quote= parameter in dbWriteTable S4 method 'SQLiteConnection,character,character'
hi, if i'm understanding things correctly, any values that match sep= inside a quoted field will derail a dbWriteTable() import from a file connection?
library(DBI)
tf <- tempfile()
x <- c( '"header1","header2"' , '"one,two","three"' )
writeLines( x , tf )
db <- dbConnect( RSQLite::SQLite() )
# works as expected
read.csv( tf )
# fails
dbWriteTable( db , 'x' , tf )
and delimited files with quotes carry those quotes into the column values.. thanks for considering this!
y <- c( '"header1","header2"' , '"onetwo","three"' )
writeLines( y , tf )
dbWriteTable( db , 'y' , tf )
# with quotes
dbReadTable( db , 'y' )[1,1]
# without quotes
read.csv( tf )[1,1]
Thanks. The code that implements this is "legacy" C code (taken from SQLite's shell.c), and there's no support for quoting in that code. Please load the data into a data frame and use the data frame method for now.
We could e.g. take code from readr and adapt it to store data in the database, avoiding the roundtrip to R.
I'm open to including better CSV import in RSQLite, I don't have the bandwidth to add it myself.