I was having an issue getting the following error with RSQLite and was having trouble diagnosing the problem:
Error in result_create(conn@ptr, statement) : too many SQL variables
The database showed the correct, fixed number (24) of columns and should have had ~190 rows. Because the many rows at once won't fit in RAM, each entry (row) is iteratively appended.
Unfortunately it kept failing on entry 99. However, when I tried to only enter rows 95 to 105 into a database, it works.
# Doesn't work
samplesToAdd <- samplesToAdd[1:100, ]
newDatabase2 <- DBI::dbConnect(RSQLite::SQLite(),
"C:/Users/chase/Documents/GitHub/IDBac_App/inst/app/SpectraLibrary/z1.sqlite")
IDBacApp::addNewLibrary(samplesToAdd = samplesToAdd,
newDatabase = newDatabase2,
selectedIDBacDataFolder = selectedIDBacDataFolder)
Warning: Error in result_create: too many SQL variables
# Works
samplesToAdd <- samplesToAdd[95:105, ]
newDatabase2 <- DBI::dbConnect(RSQLite::SQLite(),
"C:/Users/chase/Documents/GitHub/IDBac_App/inst/app/SpectraLibrary/z1.sqlite")
IDBacApp::addNewLibrary(samplesToAdd = samplesToAdd,
newDatabase = newDatabase2,
selectedIDBacDataFolder = selectedIDBacDataFolder)
So, why was this failing for "too many variables" when there were only 24?