Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature request: allow quote= parameter in dbWriteTable S4 method 'SQLiteConnection,character,character' #249

Open
ajdamico opened this issue Jan 23, 2018 · 2 comments

Comments

@ajdamico
Copy link

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]
@krlmlr
Copy link
Member

krlmlr commented Apr 30, 2018

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.

@krlmlr
Copy link
Member

krlmlr commented Dec 27, 2020

I'm open to including better CSV import in RSQLite, I don't have the bandwidth to add it myself.

@krlmlr krlmlr added this to the 2.3.0 milestone Sep 14, 2021
@krlmlr krlmlr added feature and removed enhancement labels Nov 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants