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

"Error in value[[3L]](cond) : unable to open database file" occurs frequently #47

Open
OhStan opened this issue Oct 25, 2021 · 4 comments

Comments

@OhStan
Copy link

OhStan commented Oct 25, 2021

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,

@MaxCntt
Copy link

MaxCntt commented Jan 11, 2022

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

@ggrothendieck
Copy link
Owner

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.

@OhStan
Copy link
Author

OhStan commented Jan 11, 2022

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.

@MaxCntt
Copy link

MaxCntt commented Jan 12, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants