def insert_tbl_player_power(self, tbl_player_power: List[TblPlayerPower]): with ConnectionManager() as manager: for power in tbl_player_power: q = self.q_insert_tbl_player_power.format( power.int_player_id, power.int_shot_power, power.int_jumping, power.int_stamina, power.int_strength, power.int_long_shots) manager.cur.execute(q) manager.con.commit()
def insert_tbl_player_skill(self, tbl_player_skill: List[TblPlayerSkill]): with ConnectionManager() as manager: for skill in tbl_player_skill: q = self.q_insert_tbl_player_skill.format( skill.int_player_id, skill.int_dribbling, skill.int_curve, skill.int_fk_accuracy, skill.int_long_passing, skill.int_ball_control) manager.cur.execute(q) manager.con.commit()
def get_team_id_by_url(self, tbl_team_url): with ConnectionManager() as manager: manager.cur.execute(self.q_get_team_id_by_url.format(tbl_team_url)) result = manager.cur.fetchone() if result is not None: return result[0] else: return None
def insert_tbl_player_movement( self, tbl_player_movement: List[TblPlayerMovement]): with ConnectionManager() as manager: for movement in tbl_player_movement: q = self.q_insert_tbl_player_movement.format( movement.int_player_id, movement.int_acceleration, movement.int_sprint_speed, movement.int_agility, movement.int_reactions, movement.int_balance) manager.cur.execute(q) manager.con.commit()
def insert_tbl_player_goalkeeping( self, tbl_player_goalkeeping: List[TblPlayerGoalkeeping]): with ConnectionManager() as manager: for goalkeeping in tbl_player_goalkeeping: q = self.q_insert_tbl_player_goalkeeping.format( goalkeeping.int_player_id, goalkeeping.int_diving, goalkeeping.int_handling, goalkeeping.int_kicking, goalkeeping.int_positioning, goalkeeping.int_reflexes) manager.cur.execute(q) manager.con.commit()
def insert_tbl_player_defending( self, tbl_player_defending: List[TblPlayerDefending]): with ConnectionManager() as manager: for defending in tbl_player_defending: q = self.q_insert_tbl_player_defending.format( defending.int_player_id, defending.int_defensive_awareness, defending.int_standing_tackle, defending.int_sliding_tackle) manager.cur.execute(q) manager.con.commit()
def insert_tbl_player_attacking( self, tbl_player_attacking: List[TblPlayerAttacking]): with ConnectionManager() as manager: for attacking in tbl_player_attacking: q = self.q_insert_tbl_player_attacking.format( attacking.int_player_id, attacking.int_crossing, attacking.int_finishing, attacking.int_heading_accuracy, attacking.int_short_passing, attacking.int_volleys) manager.cur.execute(q) manager.con.commit()
def insert_tbl_player_speciality( self, tbl_player_speciality: List[TblPlayerSpeciality]): with ConnectionManager() as manager: for speciality_object in tbl_player_speciality: for speciality in speciality_object: q = self.q_insert_tbl_player_specialities.format( speciality.int_player_id, speciality.str_player_speciality.replace("'", "''")) manager.cur.execute(q) manager.con.commit()
def insert_tbl_player_traits(self, tbl_player_traits: List[TblPlayerTrait]): with ConnectionManager() as manager: for traits_object in tbl_player_traits: for traits in traits_object: q = self.q_insert_tbl_player_traits.format( traits.int_player_id, traits.str_trait.replace("'", "''")) manager.cur.execute(q) manager.con.commit()
def insert_tbl_player_mentality( self, tbl_player_mentality: List[TblPlayerMentality]): with ConnectionManager() as manager: for mentality in tbl_player_mentality: q = self.q_insert_tbl_player_mentality.format( mentality.int_player_id, mentality.int_aggression, mentality.int_interceptions, mentality.int_positioning, mentality.int_vision, mentality.int_penalties, mentality.int_composure) manager.cur.execute(q) manager.con.commit()
def insert_tbl_team_tactic(self, tbl_team_tactics): with ConnectionManager() as manager: for tbl_team_tactic in tbl_team_tactics: q = self.q_insert_tbl_team_tactics.format( tbl_team_tactic.int_team_id, tbl_team_tactic.str_defensive_style.replace("'", "''"), tbl_team_tactic.int_team_width, tbl_team_tactic.int_depth, tbl_team_tactic.str_offensive_style.replace("'", "''"), tbl_team_tactic.int_width, tbl_team_tactic.int_players_in_box, tbl_team_tactic.int_corners, tbl_team_tactic.int_freekicks) manager.cur.execute(q) manager.con.commit()
def insert_tbl_player_profile(self, tbl_player_profile: List[TblPlayerProfile]): with ConnectionManager() as manager: for profile in tbl_player_profile: q = self.q_insert_tbl_player_profile.format( profile.int_player_id, profile.str_preferred_foot.replace("'", "''"), profile.int_weak_foot, profile.int_skill_moves, profile.int_international_reputations, profile.str_work_rate.replace("'", "''"), profile.str_body_type.replace("'", "''")) manager.cur.execute(q) manager.con.commit()
def get_tbl_player_image_urls(self): tbl_player_image_urls = [] with ConnectionManager() as manager: manager.cur.execute(self.q_get_tbl_player_image_urls) rows = manager.cur.fetchall() for row in rows: tbl_player = TblPlayer() tbl_player.int_player_id = row[0] tbl_player.str_player_image_url = row[1] tbl_player_image_urls.append(tbl_player) return tbl_player_image_urls
def generate(): with ConnectionManager() as manager: for query in queries: manager.cur.execute(query[1]) result = manager.cur.fetchall() # Column names col_names = [] for name in manager.cur.description: col_names.append(name[0]) df = pd.DataFrame(result, columns=col_names) df.to_csv(query[0], index=False)
def get_tbl_player_urls(self): """ Returns 500 not crawled tbl_player_urls """ tbl_player_urls = [] with ConnectionManager() as manager: manager.cur.execute(self.q_get_tbl_player_urls) rows = manager.cur.fetchall() for row in rows: tbl_player_url = TblPlayerUrl() tbl_player_url.int_player_id = row[0] tbl_player_url.str_url = row[1] tbl_player_url.dt_crawled = row[2] tbl_player_urls.append(tbl_player_url) return tbl_player_urls
def insert_tbl_team(self, tbl_teams): with ConnectionManager() as manager: for tbl_team in tbl_teams: q = self.q_insert_tbl_team.format( tbl_team.int_team_id, tbl_team.str_team_name.replace( "'", "''"), # Escape single quotes tbl_team.str_league.replace("'", "''"), tbl_team.int_overall, tbl_team.int_attack, tbl_team.int_midfield, tbl_team.int_defence, tbl_team.int_international_prestige, tbl_team.int_domestic_prestige, tbl_team.int_transfer_budget) manager.cur.execute(q) manager.con.commit()
def insert_tbl_player(self, tbl_players: List[TblPlayer]): with ConnectionManager() as manager: for tbl_player in tbl_players: q = self.q_insert_tbl_player.format( tbl_player.int_player_id, tbl_player.str_player_name.replace("'", "''"), tbl_player.str_positions.replace("'", "''"), tbl_player.dt_date_of_birth, tbl_player.int_height, tbl_player.int_weight, tbl_player.int_overall_rating, tbl_player.int_potential_rating, tbl_player.str_best_position.replace("'", "''"), tbl_player.int_best_overall_rating, tbl_player.int_value, tbl_player.int_wage, tbl_player.str_player_image_url, tbl_player.int_team_id, tbl_player.str_nationality.replace("'", "''")) manager.cur.execute(q) manager.con.commit()
from utils.db_connection_manager import ConnectionManager from controllers.controllers import Controllers from models.models import TblTeamUrl with ConnectionManager() as manager: tbl_team_url = TblTeamUrl() tbl_team_url.str_url = "testing.com" manager.cur.execute( Controllers.insert_tbl_team_urls.format(tbl_team_url.dt_crawled)) manager.con.commit()
def insert_tbl_player_urls(self, tbl_player_urls): with ConnectionManager() as manager: for player_url in tbl_player_urls: manager.cur.execute( self.q_insert_tbl_player_urls.format(player_url)) manager.con.commit()