@@ -67,32 +67,32 @@ def setupDB():
select pin,pp.country_code,rating_before,rating_after,ts.country_code,datum
from players_performance as pp join tournaments as ts on pp.tournament_code=ts.code
""")
cursor.execute("""create index pp_pin on players_performance (pin)""")
cursor.execute("""create index pp_tournament_code on players_performance (tournament_code)""")
cursor.execute("""create index pp_country_ind on players_performance (country_code)""")
cursor.execute("""create index t_datum_ind on tournaments (datum)""")
connection.commit()
def fillDB(tournaments,players):
cursor=connection.cursor()
cursor.execute("""delete from players_performance""")
cursor.execute("""delete from players""")
cursor.execute("""delete from tournaments""")
cursor.executemany(
"""insert into tournaments (code,datum,class,round_count,player_count,country_code,description) values (:code,:date,:class,:roundCount,:playerCount,:countryCode,:description)""",
tournaments.values()
)
cursor.executemany("""insert or ignore into players (pin,name) values (:pin,:name)""", players)
cursor.executemany("""insert or replace into players (pin,name) values (:pin,:name)""", players)
"""insert into players_performance (pin,tournament_code,country_code,club,win_count,game_count,rating_before,rating_after) values (:pin,:tournamentCode,:countryCode,:club,:winCount,:gameCount,:rating1,:rating2)""",
players
@@ -4,41 +4,43 @@
Funkce pro načtení dat vyexportovaných z veřejného rozhraní EGD a jejich konverzi do SQLite databáze.
## setup.py
Načte soubory tlist.html a all.hst (z aktivního adresáře) a vytvoří soubor egd.db s databází.
## queries.py
Uložené dotazy.
## Schéma databáze
### tournaments
* (text) code
* (text) datum
* (text) class
* (integer) round_count
* (integer) player_count
* (text) country_code
* (text) description
### players
* (integer) pin
* (text) name
### players_performance
Co se vztahuje zároveň k hráči a k turnaji. Většina položek all.hst.
* (text) tournament_code
* (text) club
* (integer) win_count
* (integer) game_count
* (real) rating_before
* (real) rating_after
### players_performance_tournaments
Pohled na tournaments a players_performance.
* (text) p_country_code - země hráče
* (text) t_country_code - lokace turnaje
Status change: