title: Inserting list items into database as separate entries
body: <p>I have an input field that is basically a comma delimited string (i.e. something like "deniscm, toms, peters"). That information is sent via AJAX to my Python handler SaveQueryPage. What I want to do is parse this information as a list and then insert each entry into my database. My code is as follows, but it doesn't work unfortunately. Any suggestions?</p>
  
  <p><strong>Python code:</strong></p>
  
  <pre><code>class SaveQueryPage(webapp2.RequestHandler):
    def post(self):
      user = users.get_current_user()
      user_nickname = user.nickname()
      query_name = self.request.get('queryName')
      query_collab = self.request.get('queryCollab')
  
      query_collaborators = re.split(r'\s*[,]\s*', query_collab.strip())
      query_collaborators = query_collaborators.append(user_nickname)
      query_collaborators = filter(None, query_collaborators)
  
      conn = rdbms.connect(instance=_INSTANCE_NAME, database='queryInfo')
      cursor = conn.cursor()
      cursor.execute('INSERT INTO queries (userNickname, queryName) VALUES (%s, %s)', (user_nickname, query_name))
      conn.commit()
  
      for item in query_collaborators:
        cursor = conn.cursor()
        cursor.execute('INSERT INTO collaborators (queryName, userNickname) VALUES (%s, %s)', (query_name, item))
        conn.commit()
  
      conn.close()
  </code></pre>