title: Upsert data.table into SQL database?
body: <p>What is the easiest way to update/insert an R <code>data.table</code> instance into an SQL database (e.g. MySQL)?  I have an instance of <code>data.table</code> with some key columns configured (via <code>setkey</code>). Now I'd like to <code>update</code> a corresponding SQL table whenever the table's primary key columns matches the table's keys (or I can map it manually) but for those rows which keys doesn't match, <code>insert</code> them.</p>
  
  <p>Preferably I don't need to write the SQL for it myself. One reason is the relatively many number of data columns. Another reason is that I'd like database independence (primarily easy switching between MySQL, PostgreSQL and SQLite).</p>