Search code examples
mysqlrdatabasermysql

RMySQL update row, not full table


Does anyone know how I can use RMySQL (or another library) to update a row in a table, rather than having to pull out the full table and push it back in? I don't want to read such a huge table into memory just to update one row.

What I am trying to do is pull out a row, change some of the values in there within R and push the same row object back into the table.

However, dbWriteTable seems to replace the entire table rather than just the row I specify.


Solution

  • The easiest way is to construct a string within R containing the adequate SQL Update statement and use dbSendQuery to push your data back into the table.