[Rails] Re: Using Sqlite3 Activerecord with multiple clients

Alex Young
2006-02-20T07:57:26Z

Ed wrote:
> Ed wrote:
>> However it seems that the activerecord adapter for sqlite3 is
>> locking the db file. In other words when I try to access the db
>> file, I kept on getting "database is locked" error.
That''s not surprising.  SQLIte3 is designed for single-process access.
 From sqlite.org:

> SQLite uses reader/writer locks on the entire database file. That
> means if any process is reading from any part of the database, all
> other processes are prevented from writing any other part of the
> database. Similarly, if any one process is writing to the database,
> all other processes are prevented from reading any other part of the
> database. For many situations, this is not a problem. Each
> application does its database work quickly and moves on, and no lock
> lasts for more than a few dozen milliseconds. But there are some
> applications that require more concurrency, and those applications
> may need to seek a different solution.

>> Am I wrong in choosing sqlite3 as the db backend?
In a word, yes.  If you want more than one point of access to the
database, you either want a different database engine, or to force all
access through Rails.

> Also how do I make
>> the activerecord to only lock the file when it write to the file?
I believe it does.  However, reading also causes a lock on the entire
database.

You can still use sqlite *if* you can arrange your other process to use
Rails to make the writes.

--
Alex