def anaylysiscount(): dbhelper = MysqlHelper.DbHelper() total = dbhelper.fetchCount("select count(*) from maoyan") am = dbhelper.fetchCount("select count(*) from 'newdatabase'.'maoyan'where time like '%美国%'") china = dbhelper.fetchCount("select count(*) from 'newdatabase'.'maoyan'where time like '%中国%'") japan = dbhelper.fetchCount("select count(*) from 'newdatabase'.'maoyan'where time like '%日本%'") print(total,am,japan,china)
def write2SQL(item): """ 将返回的数据插入到数据库中 :param item: :return: """ dbhelper = MysqlHelper.DbHelper() title = item['title'] actor = item['stars'].split(":")[1] time = item['releasetime'].split(":")[1] sql = "INSERT INTO newdatabase.maoyan(title,actor,time) VALUES(%s,%s,%s)" params = (title, actor, time) result = dbhelper.execute(sql, params) if result == True: print("插入成功") else: print("插入失败")