[GRASS-user] sqlite db locking blocking

Hamish hamish_b at yahoo.com
Wed Feb 23 00:19:55 EST 2011


Hi,

does SQLite let you both read and write to the DB same at the same time?
-or-, why would sqlite lock the DB on a read/select?

I'm trying to read two attribute column numbers, feed them into an
equation in awk, compose a SET,WHERE sql string, and pipe that back
into db.execute in a single step.

v.db.addcol map column="new DOUBLE PRECISION"
v.db.select map column=cat,old  | awk -F'|' \
    '{printf("UPDATE map SET new=%f WHERE cat=%d;\n", cos($2), $1)}' \
  | db.execute

the error looks like:
---
DBMI-SQLite driver error:
Error in sqlite3_step():
database is locked

ERROR: Error while executing: 'UPDATE map SET new=0.000000 WHERE cat=0'
---

(there is no cat 0 in the data)

It works for a few dozen rows of data, but not when I scale up the
attribute db to 10s of thousands of entries.

Is it possible to avoid writing out a temp file and doing it in two steps?

If there's just a single sqlite.db for the entire mapset, will I get the
same thing if I read/send the output to a different map's table in the
same mapset?


?
thanks,
Hamish


More information about the grass-user mailing list