title: PyMySQL executemany with ON DUPLICATE
body: <p>I have a list composed of dictionaries called <code>member</code> that I was inserting on a database like so</p>
  
  <pre><code>    # Executes query for each dictionary in member.
      cursor.executemany("INSERT INTO `Citizens` (`Handle`,`Org`,`Role`, "
                         "`Rank`,`Visibility`,`Stars`,`Type`) VALUES "
                         "(%(handle)s,%(sid)s,%(roles)s,%(rank)s,"
                         "%(visibility)s,%(stars)s,%(type)s)", member)
      # Commits changes to the database.
      conn.commit()
  </code></pre>
  
  <p>It worked perfectly, but as I began having issues with duplicate members I decided to add an <code>ON DUPLICATE</code> clause. The idea is that if a member is duplicate we want to update his <code>Org</code> column by concatenating the new data. So I changed the code to this</p>
  
  <pre><code>    # Executes query for each dictionary in member.
      cursor.executemany("INSERT INTO `Citizens` (`Handle`,`Org`,`Role`, "
                         "`Rank`,`Visibility`,`Stars`,`Type`) VALUES "
                         "(%(handle)s,%(sid)s,%(roles)s,%(rank)s,"
                         "%(visibility)s,%(stars)s,%(type)s) ON DUPLICATE"
                         " KEY UPDATE `Org`=concat(ifnull(`Org`, \"\"), "
                         "\", \", %(sid)s);", member)
      # Commits changes to the database.
      conn.commit()
  </code></pre>
  
  <p>However in doing so I got the following error:</p>
  
  <pre><code>There was a problem inserting member(s): (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '('real_lethality','000',0,'Master','visible',5,'affiliate') ON DUPLICATE KEY UPD' at line 3")
  Would you like to see the failed SQL query?[Y/n]
  b'INSERT INTO `Citizens` (`Handle`,`Org`,`Role`, `Rank`,`Visibility`,`Stars`,`Type`) VALUES \n(\'fullmetaljim\',\'000\',\'Founder\',\'Master\',\'visible\',5,\'main\') ON DUPLICATE KEY UPDATE `Org`=concat(ifnull(`Org`, ""), ", ", \'000\'),\n(\'real_lethality\',\'000\',0,\'Master\',\'visible\',5,\'affiliate\') ON DUPLICATE KEY UPDATE `Org`=concat(ifnull(`Org`, ""), ", ", \'000\')\n;'
  </code></pre>
  
  <p>Have I implemented the <code>ON DUPLICATE</code> wrongly? How can I make this work correctly?</p>
  
  <p>Sample <code>member</code>:</p>
  
  <pre><code>[
      {'roles': [],
       'rank': 'No SCB account',
       'type': 'main',
       'stars': 2,
       'visibility': 'visible',
       'sid': 'imperium',
       'handle': 'freakyeagle'
      },
      {'roles': [],
       'rank': 'Fleet Member',
       'type': 'main',
       'stars': 1,
       'visibility': 'visible',
       'sid': 'imperium',
       'handle': 'cadimus'},
      {'roles': [],
       'rank': 'Fleet Member',
       'type': 'main',
       'stars': 1,
       'visibility': 'visible',
       'sid': 'imperium',
       'handle': 'belleal'}
  ]
  </code></pre>
  
  <p><strong>EDIT:</strong> As it seems this might be a bug in PyMySQL itself, would anyone be able to confirm so?</p>