error in sql..
Hi,i m facing problem in mysql line, plz help me,i m unable to get solution.......
import MySQLdb
import urllib
import json
from bs4 import BeautifulSoup
tdd=json.loads(urllib.urlopen('https://www.coursera.org/maestro/api/topic/list2').read())
tsl=tdd['unis']
try:
conn=MySQLdb.connect(host="127.0.0.1",
user="root",
passwd="avnesh27",
db="course_detail",port=3306)
x= conn.cursor()
result = []
for i in range(len(tsl)):
home_link = tsl[i]['home_link']
cor_id = tsl[i]['id']
name = tsl[i]['name']
sql = "Select uni_id , name from universities where EXISTS(uni_id = cor_id and name = name"
result = x.execute(sql)
if (result):
sql = "insert into universites (uni_id, home_link,name) values(%d, %s, %s)" %(cor_id, home_link, name)
x.execute(sql)
conn.commit()
conn.close()
except Exception, e:
print "Error %s" % e
error is--
Error (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'uni_id = cor_id and name = name' at line 1")
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home