Why won't this python script input into a MySQL table I set up?

I'm trying to pull data from the YouTube API into a local MySQL table. I went through a bunch of debugging until I landed on the below script, but I get no errors from this script, so I'm a bit lost. Anyone have any suggestions where to begin?

#!/usr/bin/python
# -- coding: utf-8 --

import MySQLdb
import os
import requests
import json
import sys
import re
import requests
import datetime

sql_conn = MySQLdb.connect(host="localhost", user="root", passwd="PSWD", db="researchyoutube")
sql_conn.autocommit(True)
sql_db = sql_conn.cursor(MySQLdb.cursors.DictCursor)

resp = requests.get("https://gdata.youtube.com/feeds/api/videos?q=kitten&orderby=published&start-index=11&max-results=50&v=2&alt=jsonc")

if(resp.status_code == 200):
    data = json.loads(resp.content) 
    for item in data['data']['items']:

        title = item['title']
        uploaded_on = item['uploaded']
        description = item['description']
        video_length = item['duration']
        user = item['uploader']
        video_id = item['id']
        video_url = item['player']['default']

        sql = "INSERT IGNORE into NCII (title, uploaded_on, description, video_length, user, video_id, video_url) VALUES (title, uploaded_on, description, video_length, user, video_id, video_url)"

        sql_db.execute(sql)

Answers


Looks like your VALUES() list contains the variable names rather than the appropriate %s placeholders

sql = "INSERT IGNORE into NCII (title, uploaded_on, description, video_length, user, video_id, video_url) VALUES (%s, %s, %s, %s, %s, %s, %s)"

# execute with the vars in a tuple
sql_db.execute(sql, (title, uploaded_on, description, video_length, user, video_id, video_url))

Need Your Help

Removing the toolbar from Sencha Picker

extjs toolbar picker

I am trying to remove the toolbar from Sencha Picker (I only need the scrolling area with the event 'pick') - but nothing seems to work. The problem is that we must copy the sencha docs code of Pic...