Save game history to table in database
This commit is contained in:
parent
1acf56d1b9
commit
6393f006e8
24
database.py
24
database.py
|
@ -66,6 +66,14 @@ def initialcheck():
|
|||
owner_id integer
|
||||
); """
|
||||
|
||||
history_table_check_string = """ CREATE TABLE IF NOT EXISTS history (
|
||||
id integer PRIMARY Key,
|
||||
Team_1 text NOT NULL,
|
||||
Team_1_Score integer,
|
||||
Team_2 text NOT NULL,
|
||||
Team_2_Score integer
|
||||
);"""
|
||||
|
||||
if conn is not None:
|
||||
c = conn.cursor()
|
||||
c.execute(soulscream_table_check_string)
|
||||
|
@ -73,6 +81,7 @@ def initialcheck():
|
|||
c.execute(player_table_check_string)
|
||||
c.execute(player_stats_table_check_string)
|
||||
c.execute(teams_table_check_string)
|
||||
c.execute(history_table_check_string)
|
||||
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
@ -294,3 +303,18 @@ def add_stats(player_game_stats_list):
|
|||
c.execute(f"UPDATE stats SET {stat} = ? WHERE name=?",(player_stats_dic[stat],name))
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
def cache_history(Team_1, Team_1_Score, Team_2, Team_2_Score):
|
||||
conn = create_connection()
|
||||
store_string = """ INSERT INTO history(Team_1, Team_1_Score, Team_2, Team_2_Score)
|
||||
VALUES (?,?,?,?) """
|
||||
|
||||
if conn is not None:
|
||||
c = conn.cursor()
|
||||
c.execute(store_string, (Team_1, Team_1_Score, Team_2, Team_2_Score))
|
||||
conn.commit()
|
||||
|
||||
conn.close()
|
||||
|
||||
def get_history():
|
||||
pass
|
||||
|
|
|
@ -690,6 +690,7 @@ async def watch_game(channel, newgame, user = None):
|
|||
channel, game, user_mention = gamesqueue.pop(0)
|
||||
queue_task = asyncio.create_task(play_from_queue(channel, game, user_mention))
|
||||
await queue_task
|
||||
db.cache_history(newgame.teams['home'].name, newgame.teams["home"].score, newgame.teams['away'].name, newgame.teams['away'].score)
|
||||
|
||||
async def play_from_queue(channel, game, user_mention):
|
||||
await channel.send(f"{user_mention}, your game's ready.")
|
||||
|
|
Loading…
Reference in New Issue
Block a user