paper-dynasty-card-creation/post_raw_player_csv.py
Cal Corum 0a17745389 Run black and ruff across entire codebase
Standardize formatting with black and apply ruff auto-fixes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 14:24:33 -05:00

42 lines
1.0 KiB
Python

import asyncio
import json
import sys
from db_calls import db_delete, db_get, db_post
async def post_players(args):
with open(args[0], "r") as file:
data = json.load(file)
print(f"1st row: {data[0]}")
print(f"40th row: {data[39]}")
confirm_send = input("Should I post this player list? ")
count = 0
p_query = await db_get("players", params=[("cardset_id", 23)])
if p_query["count"] > 0:
print(f'Need to delete {p_query["count"]} existing players first...')
for player in p_query["players"]:
await db_delete("players", object_id=player["player_id"])
print("Deletions are done!")
if confirm_send.lower() in ["y", "yes", "yee", "confirm", "please"]:
print(f"I will post these {len(data)} records now...")
for player in data:
await db_post(endpoint="players", payload=player)
count += 1
print(f"All done! Final count: {count}")
# async def update_players():
if __name__ == "__main__":
asyncio.run(post_players(sys.argv[1:]))