def __init__(self, stop_resource='./resources/stopwords.txt'): words_to_skip = set() script_dir = path.dirname(__file__) file_path = path.join(script_dir, stop_resource) with open(file_path, 'r') as stop_words_resource: for word in stop_words_resource.read().split('\n'): words_to_skip.add(word) self.words_to_skip = words_to_skip self.analyzer = analyze.Analyzer() # write_dir = 'output ' + str(datetime.now()) write_dir_loc = path.join(script_dir, 'resources', 'output', datetime.now().date().isoformat()) write_dir = pathlib.Path(write_dir_loc).mkdir(parents=True, exist_ok=True) self.write_directory = write_dir_loc self.cache = db.Db()
return False def main(historyDay): for i in range(0, historyDay): currentTime = int(time.time()) - 86400 * i searchTime = time.strftime("%Y%m%d", time.localtime(currentTime)) do(searchTime) def do(searchTime): for i in range(1, 50): page = i data = doData(getData(searchTime, page), searchTime) if data == False: break def filterLeague(leagueName): if (leagueName[:3] == '俄罗斯') or (leagueName[:3] == '乌克兰'): return False else: return True db = db.Db('ds') historyDay = 2 main(historyDay) print('ok')
import sys sys.path.append("..") import db.db as db import time import matplotlib.pyplot as plt db = db.Db() session = '17_18' matchDataSession = 'nba_match_data_' + session matchListSession = 'nba_match_list_' + session def getMatchList(): sql = "SELECT * FROM {table}".format(table=matchListSession) data = db.find(sql) return data def getTeamData(matchId): sql = "SELECT * FROM {table} where match_id={id} AND alo_win_percentage!=50".format( table=matchDataSession, id=matchId) data = db.find(sql) return data def compareMatch(matchDataResult, match): hostData = {} guestData = {} if matchDataResult[0]['is_host'] == 1: hostData = matchDataResult[0] guestData = matchDataResult[1]
from app import app from model import recipe as rp from db import db from flask import jsonify, request, abort, make_response from utils import validation db_obj = db.Db('csv', 'data') db_connection = db_obj.get_db() @app.route('/gousto/api/v1.0/recipes', methods=['POST']) def add_recipe(): """ Add a recipe """ validate_request() recipe_obj = rp.Recipe(db_connection) row = recipe_obj.add_recipe(request.json) return jsonify(row) @app.route('/gousto/api/v1.0/recipes/<int:id>', methods=['PUT']) def update_recipe(id): """ Update recipe Args: id (int): id of recipe to update """
import sys sys.path.append("../../") import db.db as db import requests import time session = '17_18' matchListTable = 'nba_match_list_' + session matchDataTable = 'nba_match_data_' + session playerDataTable = 'nba_player_data_' + session dbObj = db.Db('nba') def getMatchList(): '''获取比赛列表信息''' todayTime = time.time() sql = "SELECT * FROM {table} WHERE match_time<{time} AND match_id not in (select match_id from {match_data_table}) and match_state!=-5".format( table=matchListTable, time=int(todayTime), match_data_table=matchDataTable) matchList = dbObj.find(sql) return matchList def curlMatchData(matchBaseInfo): '''根据比赛ID获取比赛数据''' matchId = matchBaseInfo['match_id'] matchTime = matchBaseInfo['match_time'] e = str(matchId)[1:3] first = str(matchId)[0:1]
import sys import db.db as dbModule import common.config.db as DbConfigModule dbConfig = DbConfigModule.DbConfig() config = dbConfig.getConfigs() db = dbModule.Db('ds') sql = "SELECT * from ds_push limit 1" data = db.find(sql) print(data)