sql - Most efficient "ignore if exists" in SQLite? -


once per day, hitting api 50 recent posts forum. i'm storing information in database, 1 row per post, storing author, title, , postid.

if there less 50 posts in day, there duplicate data, same posts appear twice or more. want avoid this. want "if postid exists in database, skip inserting record."

i can first fetching list of postids , saving array in program, making sure postid isn't in array before inserting; seems dumb , sloppy. surely there must way in database itself.

i've read little, , insert or replace works, seems it's not 'correct' solution. pose problem if wanted alter field in row -- hitting api again reset fields initial values.

what's smart way this?

you want insert or ignore. silently skip duplicate inserted rows, , won't modify pre-existing ones.

see the on conflict clause documentation details.


Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -