Thanks TIm

On 13 August 2015 at 15:31, Tim Streater <tim at clothears.org.uk> wrote:

> On 13 Aug 2015 at 11:34, Chris Parsonson <z2668856 at gmail.com> wrote:
>
> > Has anybody ever used this ATTTACH command?
>
> Here's what I do to move a row from one database to another (same
> table/column defs). I have to go via a temporary db (I use the :memory:
> one) since the primary key needs a new value in the second db. The original
> row in question has for example a value of 27 for its primary key (absid)
> in the following:
>
>   <connect to first database>
>   attach database ':memory:' as mem;
>   create table mem.messages as select * from main.messages where absid=27;
>   update mem.messages set absid=null;
>   attach database '/path/to/second/db' as dst;
>   insert into dst.messages select * from mem.messages;
>   delete from main.messages where absid=27;
>   <close database connection>
>
> I developed this approach (for my use case) using the sqlite3 CLI program
> to ensure the general approach worked before trying it with my programming
> language (PHP). You might benefit from doing the same.
>
> --
> Cheers  --  Tim
>
> _______________________________________________
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
>


-- 
Chris Parsonson
083 777 9261

Reply via email to