import py2neo import pymysql cnx = pymysql.connect(host='localhost', user='******', password='******', db='lahman2017', charset='utf8mb4', cursorclass=pymysql.cursors.DictCursor) fg = fct.FanGraph(auth=('neo4j', 'password'), host="localhost", port=7687, secure=False) ut.set_debug_mode(True) def load_players(): q = "SELECT playerID, nameLast, nameFirst FROM People where " + \ "exists (select * from appearances where appearances.playerID = people.playerID and yearID >= 2017)" curs = cnx.cursor() curs.execute(q) r = curs.fetchone() cnt = 0 while r is not None: print(r) cnt += 1
from dbservice import dataservice import utils.utils as ut import json ut.set_debug_mode(False) dataservice.set_config() def test_get_resource(): template = {"nameLast": "Williams", "nameFirst": "Ted"} fields = ['playerID', 'nameFirst', 'bats', 'birthCity'] result = dataservice.retrieve_by_template("people", template, fields) print("Result = ", json.dumps(result, indent=2)) def test_cache1(): # first miss then hit template = {"nameLast": "Williams", "nameFirst": "Ted"} fields = ['playerID', 'nameFirst', 'birthCity'] result = dataservice.retrieve_by_template("people", template, fields) print("Result = ", json.dumps(result, indent=2)) result = dataservice.retrieve_by_template("people", template, fields) print("Result = ", json.dumps(result, indent=2)) def test_cache2(): # cache miss template = {"nameLast": "Williams", "nameFirst": "Ted"}