title: SQLite INSERT - ON DUPLICATE KEY UPDATE (UPSERT)
body: <p>MySQL has something like this:</p>
  
  <pre><code>INSERT INTO visits (ip, hits)
  VALUES ('127.0.0.1', 1)
  ON DUPLICATE KEY UPDATE hits = hits + 1;
  </code></pre>
  
  <p>As far as I know this feature doesn't exist in SQLite, what I want to know is if there is any way to achive the same effect without having to execute two queries. Also, if this is not possible, what do you prefer:</p>
  
  <ol>
  <li><strong>SELECT + (INSERT or UPDATE)</strong> or</li>
  <li><strong>UPDATE (+ INSERT <em>if UPDATE fails</em>)</strong></li>
  </ol>