title: Trying to pull specific values from a database
body: <p>I have an sqlite3 table in python that looks like this:</p>
  
  <pre><code>CREATE TABLE words
                (ID                    INTEGER      PRIMARY KEY      AUTOINCREMENT,
                 CURRENT_WORD          TEXT     NOT NULL,
                 BEFORE_WORD           TEXT     NOT NULL,
                 AFTER_WORD            TEXT     NOT NULL,
                 OCCURANCES            INTEGER      NOT NULL)
  </code></pre>
  
  <p>It returns the following database values:</p>
  
  <pre><code>(1, u'is', u'This', u'true', 0)
  (2, u'you', u'are', u'ready', 1)
  </code></pre>
  
  <p>I'd like to be able to pull the value 'OCCURANCES' from id 2. I've tried the following, I was then planning to parse the returned value with regex, but my code doesn't appear to be working:</p>
  
  <pre><code>def db_check(db, words):
      conn = sqlite3.connect(db)
      c = conn.cursor()
      frequency = 0
      print("SELECT * FROM words WHERE CURRENT_WORD = '" + words[1] + "' AND BEFORE_WORD = '" + words[0] + "' AND AFTER_WORD = '" + words[2] + "'")
      for row in c.execute("SELECT * FROM words WHERE CURRENT_WORD = '" + words[1] + "' AND BEFORE_WORD = '" + words[0] + "' AND AFTER_WORD = '" + words[2] + "'"):
          print "FOUND: "
          print row
      conn.commit()
      if frequency == 0: frequency = 1
      return frequency
  </code></pre>
  
  <p>Any idea where I'm going wrong? I'd say it's wrong with my SQL in the last part. Is there a better way to do this, such as pulling the frequency exactly?</p>