lundi 12 janvier 2015

how does locking in sqlite work?

Background Information


I'm trying to get a better handle on how locking in sqlite works. Right now, I'm running a lua script that is attempting to add 200,000 records to a table. I'm doing something like this:



luasql = require("luasql.sqlite3")
local env = assert(luasql.sqlite3())
local conn = env:connect("widgets.db")
for i = 10000 , 250000, 1 do
local sql = "insert into test values("..i..","..i..",'widget','test description')"
print(sql)
conn:execute(sql)
end
conn:close()


The script seems to be taking a long time... in that it's adding a record or two each second. Not too too fast. But that's not the question / issue I have.


Problem While this script is running, I just tried to launch another application that also attempts to read from the same database, same widgets table. But its failing with an error that the database is locked.


Question While the database is being updated, should I be able to read from it from other processes / applications?


I've been searching on stackoverflow for similar posts but haven't found anything that directly answers my question.


Any suggestions would be appreciated


Aucun commentaire:

Enregistrer un commentaire