Python MySQLdb Insert TypeError: not all arguments converted during string formatting -


i trying insert values database

urls =("http://www.**********.net/?page=match") hdr = {'user-agent': 'mozilla/5.0'} req = urllib2.request(urls,headers=hdr) page = urllib2.urlopen(req) soup = beautifulsoup(page)  tournament = soup.find('div',{'class':['content-body']}) match_times = tournament.find_all("div", style = "width:10%; float:left;") match_names = tournament.find_all("div", style = "width:46%; float:left; margin-left:2%; margin-right:2%") tournys = tournament.find_all("div", style = "width:40%; float:left; overflow:hidden;")   element in zip(match_times, match_names, tournys):     results = element[0].text, element[1].text, element[2].text     matchday=datetime.strptime(results[0], "%d/%m/%y").strftime("%d-%m-%y")     info= results[1],results[2],matchday     conn= mysqldb.connect(host='localhost',user='root',passwd='',db='sport')     c = conn.cursor()     query = "insert todaysmatches (match, tournament, matchdate) values (%s,%s,%s)"     c.executemany(query, info)     conn.commit()     conn.close()     print  info     print '===================' 

match varchar(150) , tournament varchar(150) , matchdate date

this example of printed info:

(u'\n\xa0bestest \n9 - 16\ntrypants\xa0\n\n', u'\xa0razer cs:go tournament', '08-12-2013') 

try changing line:

# expects list it's second argument, giving tuple. c.executemany(query, info) 

to this:

c.executemany(query, [info]) 

if works, may want read docs, , find out if there better way of inserting data when have insert 1 row. (there is.)


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -