On 04/04/2011 05:16 PM, Robert Poor wrote: > @Marcelo: > > Going back to your original question: do you really only want to > insert one item at a time? If so, I think your question has been > answered reasonably well. > > BUT: if you have a large number of items, and you want to insert items > that aren't yet in the table, then you can do it efficiently in a > single query. Check the documentation for "INSERT OR IGNORE", i.e. > > http://sqlite.org/lang_insert.html > > Also, you say a new item is to be "inserted only if this item is not > yet in that table", but you haven't described how you discriminate a > new item from an existing item. Obviously you are not comparing > primary keys (since the new item won't have a primary key) -- do you > mean to compare all of the other fields? > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users Thx for answering Robert,
In principle I want to include one at a time ... because I am parsing web sites. So after each parsing I insert the results in the database. About the "new" item, yes I do compare some specific fields and not the primary key. For example name and surname of a person ... I look in the database for such a person ... if yes I return her id ... if not I include her and then return her id ... so I thought it would be more efficient to construct a single query that does all the job avoiding multiple queries. I need that id to process other tables that is why I am doing one at a time. best -- Marcelo S Zanetti _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users