title: Sqlite db, multiple row updates: handling text and floats
body: <p>I have a large SQLite database with a mix of text and lots of other columns <code>var1</code> ... <code>var 50</code>. Most of these are numeric, though some are text based.</p>
  
  <p>I am trying to extract data from the database, process it in python and write it back - I need to do this for all rows in the db.</p>
  
  <p>So far, the below sort of works:</p>
  
  <pre><code># get row using select and process
  fields = (','.join(keys)) # "var1, var2, var3 ... var50"
  results = ','.join([results[key] for key in keys]) # "value for var1, ... value for var50"
  cur.execute('INSERT OR REPLACE INTO results (id, %s) VALUES (%s, %s);' %(fields, id, results))
  </code></pre>
  
  <p>This however, nulls the columns that I don't explicitly add back. I can fix this by re-writing the code, but this feels quite messy, as I would have to surround with quotes using string concatenation and rewrite data that was there to begin with (i.e. the columns I didn't change).</p>
  
  <p>Apparently the way to run updates on rows is something like this:</p>
  
  <pre><code>update table set var1 = 4, var2 = 5, var3="some text" where id = 666;
  </code></pre>
  
  <p>Presumably the way for me would be to run <code>map</code> , and add the <code>=</code> signs somehow (not sure how), but how would I quote all of the results appropriately (Since I would have to quote the text fields, and they might contain quotes within them too .. )?</p>
  
  <p>I'm a bit confused. Any pointers would be very helpful.</p>
  
  <p>Thanks!</p>