0

I am using R to create a database, and then ingest data into this database. I am using a Linux VM to perform these operations, and have tried the operations with R 3.4.4 and R 3.6.3. The relevant code is:

sqlDatabase = file.path(results_folder, 'mix_database.db')
sqlConnection = dbConnect(RSQLite::SQLite(), sqlDatabase)
dbCreateTable(conn=sqlConnection, 
              name='mix', 
              fields=c(
                'id'='integer', 
                'x'='numeric', 
                'y'='numeric'
                )
              )

Here results_folder is simply an output from file.path(...). The failure occurs in the dbCreateTable command. After starting with no database file, the sqlConnection command creates a mix_database.db file, and then dbCreateTable command should create a table within this database. However, I am getting the following error:

> dbCreateTable(conn=sqlConnection, 
              name='mix', 
              fields=c(
                'id'='integer', 
                'x'='numeric', 
                'y'='numeric'
                )
              )

Error: database is locked

I have a couple questions. First, has anyone else experienced this? If so, how can I solve this? Is there a way to unlock a database within R?

CopyOfA
  • 553
  • 2
  • 14
  • Rarely come across two pages of [I had that!](https://stackoverflow.com/questions/151026/how-do-i-unlock-a-sqlite-database), which overall suggest a very step by step approach. But first exit your terminal. Then perhaps don't conclude `results_folder` is just something or other, as you're trying to trace what touches, then releases chains of events to finally get to work in your db off there in a VM. `lsof` may be your friend here. – Chris Jul 22 '21 at 15:03

0 Answers0