title: Python peewee save() doesn't work as expected
body: <p>I'm inserting/updating objects into a MySQL database using the <a href="http://peewee.readthedocs.org/en/latest/index.html" rel="noreferrer">peewee</a> ORM for Python. I have a model like this:</p>
  <pre><code>class Person(Model):
      person_id = CharField(primary_key=True)
      name = CharField()
  </code></pre>
  <p>I create the objects/rows with a loop, and each time through the loop have a dictionary like:</p>
  <pre><code>pd = {&quot;name&quot;:&quot;Alice&quot;,&quot;person_id&quot;:&quot;A123456&quot;}
  </code></pre>
  <p>Then I try creating an object and saving it.</p>
  <pre><code>po = Person()
  for key,value in pd.items():
      setattr(po,key,value)
  po.save()
  </code></pre>
  <p>This takes a while to execute, and runs without errors, but it doesn't save anything to the database -- no records are created.</p>
  <p>This works:</p>
  <pre><code>Person.create(**pd)
  </code></pre>
  <p>But also throws an error (and terminates the script) when the primary key already exists. From reading the manual, I thought <a href="http://peewee.readthedocs.org/en/latest/peewee/api.html#Model.save" rel="noreferrer"><code>save()</code></a> was the function I needed -- that peewee would perform the update or insert as required.</p>
  <p>Not sure what I need to do here -- try getting each record first? Catch errors and try updating a record if it can't be created? I'm new to peewee, and would normally just write <code>INSERT ... ON DUPLICATE KEY UPDATE</code> or even <code>REPLACE</code>.</p>