title: inserting JSON object into MySQL using Python
body: <p>I'm new to python and trying to work out how to insert some JSON into MySQL table.</p>
  
  <p>How can I insert my JSON Object into MySQL using Python?</p>
  
  <p>Here is the code that I am using</p>
  
  <pre><code>import requests
  import urllib.request
  import json
  import pymysql
  
  con = pymysql.connect(host = 'localhost',user = 'root',passwd = 'root',db = 'micro')
  cursor = con.cursor()
  url = 'https://api.amazon.com/v1/products(onlineAvailability=true)?pageSize=100&amp;show=upc,sku,salePrice&amp;page=45&amp;callback=JSON_CALLBACK&amp;format=json'
  urllib.request.urlopen(url).read()
  response = urllib.request.urlopen(url).read()
  json_obj = str(response, 'utf-8')
  
  cursor.execute("INSERT INTO bestb (sku, upc, salePrice) VALUES (%s,%s,%s)", (sku, upc, salePrice))
  con.commit()
  con.close()
  
  print (json_obj)
  </code></pre>
  
  <p>here is the JSON that i'm trying to parse.</p>
  
  <pre><code>"products": [
      {
        "upc": "715187763623",
        "sku": 1833591,
        "salePrice": 13.99
      },
      {
        "upc": "8809269504036",
        "sku": 26220187,
        "salePrice": 16.99
      }
    ]
  })
  </code></pre>
  
  <p>Thanks in advance.</p>