app.py: add update_nhl_standings function and set to run every 5 min
This commit is contained in:
@@ -44,21 +44,22 @@ def extract_standings_info():
|
||||
print("Error:", response.status_code)
|
||||
return None
|
||||
|
||||
# Connect to SQLite database
|
||||
conn = sqlite3.connect("nhl_standings.db")
|
||||
def update_nhl_standings():
|
||||
# Connect to SQLite database
|
||||
conn = sqlite3.connect("nhl_standings.db")
|
||||
|
||||
# Create standings table if it doesn't exist
|
||||
create_standings_table(conn)
|
||||
# Create standings table if it doesn't exist
|
||||
create_standings_table(conn)
|
||||
|
||||
# Truncate standings table before inserting new data
|
||||
truncate_standings_table(conn)
|
||||
# Truncate standings table before inserting new data
|
||||
truncate_standings_table(conn)
|
||||
|
||||
# Extract standings info
|
||||
standings_info = extract_standings_info()
|
||||
# Extract standings info
|
||||
standings_info = extract_standings_info()
|
||||
|
||||
# Insert standings info into the database
|
||||
if standings_info:
|
||||
insert_standings_info(conn, standings_info)
|
||||
# Insert standings info into the database
|
||||
if standings_info:
|
||||
insert_standings_info(conn, standings_info)
|
||||
|
||||
# Close database connection
|
||||
conn.close()
|
||||
# Close database connection
|
||||
conn.close()
|
||||
|
||||
Reference in New Issue
Block a user