title: SQLite3 check for values in database in python
body: <p>Currently having issues getting the proper SQL commands for this example below. </p>
  
  <pre><code>title  || stock        || ids         ||
  ----------------------------------------
  item 1 || low-stock    || 883864-1096 ||
  item 1 || out-of-stock || 883864-1097 ||
  item 1 || out-of-stock || 883864-1098 ||
  item 2 || out-of-stock || 883864-1456 ||
  </code></pre>
  
  <p>The ideal is when i refresh the API json, if value in the stock column changes for that id on a new request i wish to update the database to that new value.So what would be the proper SQL command? I attempted the following: 
  (function to refresh api and parse values)</p>
  
  <pre><code>stocklevels = stocklevels
  title= title
  ids = ids
  z = (title,)
  c.execute('SELECT (title) FROM products WHERE title=?', z)
  olderstock = old_stock = c.fetchone()
  </code></pre>
  
  <p>so far, Where title=?  commands grabs the title, however, after that i am lost. 
  All help is appreciated </p>
  
  <hr>
  
  <pre><code>def loadjson():
     r = sess.get(url)
     data = r.json()
     x = data['skus']
     title = data['name']
     for l in x:
        stocklevels = l['stockLevel']
      ids = l['id']
      postit(stocklevels,title,ids)
  
  def postit(stocklevels,title,ids):
    stocklevels = stocklevels
    title= title
    ids = ids
    conn = sqlite3.connect('ports.db')
    c = conn.cursor()
    c.execute("""CREATE TABLE IF NOT EXISTS products(title TEXT,stock TEXT,ids INTERGER UNIQUE)""")
    try:
       c.execute("""INSERT INTO products (title,stock,ids) VALUES (?,?,?)""", (title,stocklevels,ids,))
    except:
        try:
         # SQL command to select rows with same title.
         # If Stocklevels != Stock  AKA if new stocklevels parsed on r  doesnt  == stock column
         # c.execute Update stocklevel
         # else pass
  
  
      except Exception as e:
          print e
  </code></pre>