def save_report_player_data(self, arr, report_type): count_sql = "select count(*) cc from test.wcl_report_player where report_id = %(report_id)s " \ "and player_name = %(player_name)s and report_type = %(report_type)s" sql = "insert into test.wcl_report_player (report_id,report_type,player_rank,player_name," \ "player_amount,player_per_second,player_performance) values " \ "(%(report_id)s, %(report_type)s, %(player_rank)s, %(player_name)s, " \ "%(player_amount)s, %(player_per_second)s, %(player_performance)s)" with utils.connect_by_code('test001') as conn: for i, o in enumerate(arr): x = utils.query_one( conn, count_sql, { "report_id": self.report.id, "player_name": o['name'], "report_type": report_type }) if x.cc == 0: utils.update( conn, sql, { "report_id": self.report.id, "report_type": report_type, "player_rank": i + 1, "player_name": o['name'], "player_amount": o['amount'], "player_per_second": o['dps'], "player_performance": o['performance'], }) pass
def save_report(report_list): count_sql = "select count(*) cc from test.wcl_report where report_id = %(report_id)s" sql = "insert into test.wcl_report (report_id,title,report_date,link) values (%(report_id)s,%(title)s,%(report_date)s,%(link)s)" with utils.connect_by_code('test001') as conn: for o in report_list: x = utils.query_one(conn, count_sql, o) if x.cc == 0: utils.update(conn, sql, o)
def run(self): sql = f""" select t.name,t.class,t1.player_amount from wcl_player t join (select * from wcl_report_player where report_id =428 and report_type = 'dmg') t1 on t.`name` = t1.player_name where t.class = 'rogue' """ with utils.connect_by_code('test001') as conn: return utils.query_list(conn, sql) pass
def save_player_data(self, arr): count_sql = 'select count(*) cc from test.wcl_player where name = %(name)s and class = %(class)s' insert_sql = 'insert into test.wcl_player (`name`,`class`) values (%(name)s,%(class)s)' with utils.connect_by_code('test001') as conn: for i, o in enumerate(arr): x = utils.query_one(conn, count_sql, { "name": o['name'], "class": o['class'] }) if x.cc == 0: utils.update(conn, insert_sql, { "name": o['name'], "class": o['class'] }) pass
def get_player_list(self): sql = 'select * from test.wcl_report_player where report_id = %(report_id)s order by player_rank' with utils.connect_by_code('test001') as conn: return utils.query_list(conn, sql, { "report_id": self.report.id })
def get_db_reportlist(self): # sql = "select * from test.wcl_report where title like '2团%' and id between 254 and 277" sql = "select * from test.wcl_report where title like '2团%' and report_date > '2020-08-08' limit 15" with utils.connect_by_code('test001') as conn: return utils.query_list(conn, sql)
def clear(self): sql = 'delete FROM `wcl_report_player` where report_id =' + str( self.report.id) with utils.connect_by_code('test001') as conn: utils.update(conn, sql)
def get_award_list(): sql = "select * from test.wcl_report where id = 428" with utils.connect_by_code('test001') as conn: return utils.query_list(conn, sql)
def get_db_reportlist(): # sql = "select * from test.wcl_report where title like '2团%' and id between 254 and 277" sql = "SELECT * FROM test.wcl_report WHERE title LIKE '2团%naxx%'and id not in " \ "(select distinct report_id from test.wcl_report_player) and report_date > '2020-10-01'ORDER BY id DESC" with utils.connect_by_code('test001') as conn: return utils.query_list(conn, sql)