title: Issue with Select Statement for MySQLdb Python
body: <p>I need to process the output of scrapy and store it to mysql using mysqldb. The below code works fine for article table however i need to access the category_id to insert in articlecategory table as foreign key. The item['channel'] is a list with categories.
  However, the below output only returns id :1 which doesnt exit.</p>
  
  <pre><code>def process_item(self, item, spider):
      try:
          self.cursor.execute(\
              "insert into article (url, pid , date)\
              values (%s, %s, %s)",
              (item['url'], item['pid'], item['pub_date'])
              )
          article_id = self.cursor.lastrowid           
          self.conn.commit()
  
          for channel in item['channels']:
              self.cursor.execute("insert ignore into category(category_name) values(%s)",([channel]))                
              self.conn.commit()          
  
              category_id = self.cursor.execute("select id from category where category_name = %s", ([channel]))
              with open("cat.txt", "a") as f:
                  f.write("id: %s \n" %  (category_id))
  </code></pre>
  
  <p>How can I access the id of category matching the category name? The syntax is working for insert operation with category table.</p>