title: How to update records in MySQL using SqlAlchemy python
body: <p>so Im attempting to updated records in database by id's.  </p>
  
  <ul>
  <li>The problem is it overwrites all rows ```id and Cost`` with the last row of the list</li>
  <li>I dont get any errors, but it should match the id's then replace only <code>Cost</code></li>
  </ul>
  
  <p>database:</p>
  
  <pre><code>table =
  
  id             Cost
  000074800795   157.05974458228403
  000074801136   80.637745302714
  000074801299    7
  000074800300   13
  000074800955   10
  
  </code></pre>
  
  <p>my code:</p>
  
  <pre class="lang-py prettyprint-override"><code>df = pd.DataFrame({ "id": [000074800795 , 000074801136, 000074801299,000074800300, 000074800955] ,
                      "Cost" : [157.05974458228403 ,80.637745302714, 7, 13, 10] }) 
  
  # replacing Null
  df = df.where((pd.notnull(df)), None)
  
  # reset index for For loop
  df = df.reset_index()
  
  df.id = df.id.astype(str)
  #df.Cost = df.Cost.astype(str)
  
  df.dtypes
  out[101]: 
  index  int64
  id    object
  Cost  object
  dtype: object
  
  values_list = []
  
  for i in range(len(df)):
      values_list.append({ "id": df["id"][i] , 
                           "Cost": df["Cost"][i] ,
                         })
  
  print(values_list[0:2])
  [{'id': '000074800795', 'Cost': 157.05974458228403}, {'id': '000074801136', 'Cost': 80.637745302714}]
  </code></pre>
  
  <p>Loading at db.  </p>
  
  <ul>
  <li><h3>The problem is it overwrite ```id and Cost`` with the last row of the list</h3></li>
  <li><p>I dont get any errors, but it should match the id's then replace only <code>Cost</code></p></li>
  </ul>
  
  <pre><code>engine = db.create_engine("my connection")
  
  connection = engine.connect()
  metadata = db.MetaData()
  
  # Creating Table
  data = db.Table('table', metadata, 
                db.Column('id', db.String(100), nullable=True),    
                db.Column('Cost', db.String(100), nullable=True),  
                extend_existing=True 
                )
  
  metadata.create_all(engine)
  
  query = db.update(data)
  ResultProxy = connection.execute(query, values_list)
  
  engine.dispose()
  </code></pre>
  
  <h2>Output:</h2>
  
  <pre><code>table =
  
  id             Cost
  000074800955   10
  000074800955   10
  000074800955   10
  000074800955   10
  000074800955   10
  </code></pre>