On Sat, 20 Dec 2008 07:03:48 -0500, Simon
<turne...@gmail.com> wrote in General Discussion of SQLite
Database <sqlite-users@sqlite.org>:

>> 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.
>
>Yes, ok, I'll have to work that way... 
>I believe there should also be some time spent 
>on a good design for these locks... 
>like to avoid congestion.  

SQLite does the locking for you, you just have to handle the
locked or busy status.

>But it'll be on my own for that one, shouldn't be difficult
>and it's not sqlite specific anyway. 
>(However, i you do have a good url to such design, please tell me!)

Just browse the two or three most recent weeks in the
mailing list archives, then get your hands dirty using the
SQL language- and C interface docs as a reference. 

>> 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
>
>I've read on ATTACH and it does seem to help a lot for my project.  But if I 
>understand right, if I'm copying data from db1 to db2 and the data is actually 
>a 
>blob...  I would have to make my SQL QUERY, then bind the data in db1 to the 
>query and then step through to actually copy it...  right?  The same method 
>could be used regardless of datatype actually to make something simple.

There is not much need to prepare/bind/step in this case,
because you just pump data from one table into another one,
without the data being returned to your application.

Most you need to know about locking is found in:
http://www.sqlite.org/lang_transaction.html

sqlite3_exec() these statements one by one:
ATTACH 'filename' as db2;
BEGIN IMMEDIATE; -- or EXCLUSIVE
(error handling/retry) 

-- this assumes table1 has the exact 
-- same definition in both db1 and db2
INSERT INTO db1.table1 SELECT * FROM db2.table1;
(error handling)

COMMIT; -- or ROLLBACK


>Thanks,
>   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