sqldf
sqldf copied to clipboard
"Error in value[[3L]](cond) : unable to open database file" occurs frequently
Hi,
When I was trying to use sqldf to join 2 data frames, it some times returned with error message "Error in value[3L] : unable to open database file", then stops there, nothing else given. Do you know what is going on?
Note: RSQLite was used. This can be resolved by commenting out some of the fields from data frames to be joint. I have converted all columns to "character" data type before calling sqldf
Thanks,
Hi, any news on this one. Since several days, I systematically get the message "Error: unable to open database file" when trying to join two tables. I'm using R memory, no external database.
My code simply look like this: sqldf("select df1.col1, df2.col2 from df1 left join df2 on df1.col1 = df2.col2")
Thanks
Have never seen this. Maybe you think you are using sqlite but are actually using something else and it needs a database? Add verbose=TRUE to the sqldf call and see if that shows anything helpful.
This seems to be kind of random, and I guess it may be related to the SQLite database not initiated properly. If it can return more info then it will certainly help us to figure out the exact cause.
Thanks for the fast reply and the verbose tip. It seems to use SQLite:
sqldf("select df.Id, df.Name, count(SC.CaseNumber) as Number_of_Case from df left join SC on df.Id = SC.AccountId group by df.Id", verbose=T)
sqldf: library(RSQLite) sqldf: m <- dbDriver("SQLite") sqldf: connection <- dbConnect(m, dbname = ":memory:") sqldf: initExtension(connection) sqldf: dbWriteTable(connection, 'df', df, row.names = FALSE) sqldf: dbWriteTable(connection, 'SC', SC, row.names = FALSE) sqldf: dbGetQuery(connection, 'select df.Id, df.Name, count(SC.CaseNumber) as Number_of_Case from df left join SC on df.Id = SC.AccountId group by df.Id') Error: unable to open database file sqldf: dbDisconnect(connection)
As we can see, both tables are written in the database and I'm able to query them individually. The error occurs with the join.