Пример #1
0
 def load_matches_to_db_and_celery(self):
     r = Requester()
     matches = r.get_player_matches(self.faceit_id, 50)
     matches_data = [(match['id'], self.faceit_id, match['started'])
                     for match in matches]
     sql = f"""
         INSERT INTO matches (faceit_id, player_faceit_id, date_played) VALUES 
          (%s, %s, to_timestamp(%s)) ON CONFLICT DO NOTHING;
         """
     con = psycopg2.connect(
         "host=13.53.197.126 port=5432 dbname=csgo user=csgo password=csgo")
     cur = con.cursor()
     cur.executemany(sql, matches_data)
     cur.close()
     con.commit()
     con.close()
     for match in matches_data:
         load_and_store_stats.delay(match[0], self.faceit_id)