On Tue, 16 Dec 2008 12:26:30 -0500, Simon
<turne...@gmail.com> wrote in turne...@gmail.com, General
Discussion of SQLite Database <sqlite-users@sqlite.org>:

>Hi there,
>  I'm developping an application that will use several databases.  One
>on disk that will hold all configuration and cache, and another in ram
>to hold all live data.
>
>  On the same server, it is possible that multiple process will
>read/write to both the disk db and the memory db.  Someone on IRC
>suggested to create a normal file db instead of memory and place it in
>a ramfs such as /dev/shm so other process can also connect to it.

That's right, only the process that created it can access an
in-memory database.

>  I'm wondering what I will need to organise to ensure stability for
>such operations (two or more processes on on database).  I beleive I
>should look into a strong locking policy, but there may be something
>else...  

Use transactions, ref:
http://www.sqlite.org/lang_transaction.html
and program proper lock/error handling. The archives of this
mailing list contain several good examples.

>Also, I will need to copy chunks of the database from one to
>the other in a similar way to a replication. I know that sqlite does
>nothing about replication, interdatabase communication, etc.  I'm just
>wondering if there could be a query made on a database using
>information provided in another database (ie to compare, or
>insert/copy).

You can ATTACH a second database (actually several databases
at the same time) to the same process. Then CREATE your
tables and use INSERT INTO .... (SELECT FROM ...) syntax to
populate tables in one database with the contents of another
one.
http://www.sqlite.org/lang_insert.html

You even can CREATE tables semi-automatically using the
CREATE TABLE .... SELECT ... syntax, but this has the
disadvantage of not creating any indexes.
http://www.sqlite.org/lang_createtable.html

>Thanks in advance,
>  Simon
-- 
  (  Kees Nuyt
  )
c[_]
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to