If the table you are modifying is not being used in the in progress queries 
then you can just do the inserts -- wrapping the whole process in a single big 
transaction if you like.  

If the inserts may affect an open cursor (query) then you can specify an ORDER 
BY on the affected query, and put a + in front of one of the column names.  
This has the effect of forcing the query results to be put into a temp b-tree 
on the first call to step, and your row retrievals cursor through the temp 
table (as it were).  This is effectively the same as retrieving the entire 
result set into a list except that the buffer is within the database engine and 
not within your application.

> -----Original Message-----
> From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-
> boun...@sqlite.org] On Behalf Of Joseph L. Casale
> Sent: Wednesday, 17 July, 2013 13:07
> To: sqlite-users@sqlite.org
> Subject: [sqlite] Guidance with Python and nested cursors
> 
> I am using Python to query a table for all its rows, for each row, I
> query related rows from a
> second table, then perform some processing and insert in to a third
> table.
> 
> What is the technically correct approach for this? I would rather not
> accumulate all of the first
> tables data to make one off selects from table two, then insert to
> table three. I would prefer to
> iterate over table one etc.
> 
> How does one setup the connection and cursor for this style of task?
> 
> Thanks for any guidance,
> jlc
> _______________________________________________
> 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