Error when writing to database in tests file #680
Unanswered
indigotechtutorials
asked this question in
Q&A
Replies: 1 comment
-
|
@indigotechtutorials Sorry for not responding sooner. A limitation of the sqlite database is that multiple threads can read at the same time, but only one thread can write (or have an open transaction) at a time. This may be what you're running into. The way frameworks like Rails generally work around this is to create one database per worker (either thread or process). Another thing you might want to try is to set a busy timeout, so threads will wait for the database to become writable. See docs at https://sparklemotion.github.io/sqlite3-ruby/SQLite3/Database.html#method-i-busy_handler_timeout-3D |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am using this gem to interact with sqlite3 using
db.executecommand to insert new records into tableI started writing tests for my app using minitest and now I'm seeing this error when running my test file with multiple methods trying to write to database I think its because of parallel running but I'm not sure why I can't write to the database at the same time as another process is.
SQLite3::ReadOnlyException: attempt to write a readonly databaseAny ideas on how to get around this? I could try to make my tests run one at a time but I'd like to find a solution
Beta Was this translation helpful? Give feedback.
All reactions