On 5/8/12 1:51 PM, "Tilsley, Jerry M." <jmtils...@st-claire.org> wrote:

>This is probably a newbie question so please bear with me.  I'm accessing
>a SQLite database through TCL and periodically I get a "Database Locked"
>error.  This is a multi-thread process that writes to the DB, do I need
>to enable WAL for this, if so, do I do this from the TCL side or the
>command-line side?

If only one thread is writing, then using WAL should do the trick; the
other threads can read while the writer is writing.  If multiple threads
are writing, that's a whole different issue, and WAL (while it might still
be a good idea) won't prevent the problem.

You enable WAL mode using the "journal_mode" pragma; once it's set it's
persistent.  So you'd want to set it when creating a new database,
wherever you do that; on an existing database, wherever you like.  See
sqlite.org/wal/html.

If you've gotten multiple writers you can set a lock timeout using the
database handle's "timeout" subcommand; it defaults to 0.0.  You'll still
need to handle lock errors, though; a timeout isn't a guarantee.

Will


--
Will Duquette -- william.h.duque...@jpl.nasa.gov
Athena Development Lead -- Jet Propulsion Laboratory
"It's amazing what you can do with the right tools."





>
>________________________________
>
>Disclaimer****
>This email is confidential and intended solely for the use of the
>individual to whom it is addressed. Any views or opinions presented are
>solely those of the author and do not necessarily represent those of St.
>Claire Regional Medical Center. If you are not the intended recipient, be
>advised that you have received this email in error and that any use,
>dissemination, forwarding, printing or copying of the email is strictly
>prohibited. If you received this email in error please notify the St.
>Claire Regional Helpdesk by telephone at 606-783-6565.
>_______________________________________________
>sqlite-users mailing list
>sqlite-users@sqlite.org
>http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to