I submited the jar packege,topology can be normal operation. but can't write the result into MySQL and can get the log.I have already create a table in my database called result
`#coding=utf-8
import MySQLdb
import logging
from pyleus.storm import SimpleBolt
log = logging.getLogger('log_results')
def write_result(freqset,count):
conn = MySQLdb.connect(host='10.1.1.5',user='root',passwd='',db='datamining',port=3306)
cur = conn.cursor()
st = ''
for i in freqset:
st = st + i + ','
sql = "select * from result where freqset = " + "'"+ st +"'"
cur.execute(sql)
returned_value = cur.fetchone()
if returned_value != None:
supnum = returned_value[1]+count
sql1 = "update result set supnum = %s where freqset = '%s';" %(str(supnum),st)
cur.execute(sql1)
conn.commit
else:
value = [st,count]
sql2 = 'insert into result values(%s,%s)'
cur.execute(sql2,value)
conn.commit()
I submited the jar packege,topology can be normal operation. but can't write the result into MySQL and can get the log.I have already create a table in my database called result `#coding=utf-8 import MySQLdb import logging
from pyleus.storm import SimpleBolt
log = logging.getLogger('log_results')
def write_result(freqset,count): conn = MySQLdb.connect(host='10.1.1.5',user='root',passwd='',db='datamining',port=3306) cur = conn.cursor() st = '' for i in freqset: st = st + i + ',' sql = "select * from result where freqset = " + "'"+ st +"'" cur.execute(sql) returned_value = cur.fetchone() if returned_value != None: supnum = returned_value[1]+count sql1 = "update result set supnum = %s where freqset = '%s';" %(str(supnum),st) cur.execute(sql1) conn.commit else: value = [st,count] sql2 = 'insert into result values(%s,%s)' cur.execute(sql2,value) conn.commit()
class LogResultsBolt(SimpleBolt):
if name == 'main': logging.basicConfig( level=logging.DEBUG, filename='/tmp/results.log', format="%(message)s", filemode='a', )
`