Add random position.

main
Joshua Potter 2023-12-07 08:08:53 -07:00
parent 44a18fc59c
commit 8f21cb64af
2 changed files with 7 additions and 1 deletions

View File

@ -1,3 +1,4 @@
import random
import sys import sys
from datetime import datetime from datetime import datetime
from typing import List, Literal from typing import List, Literal
@ -129,6 +130,7 @@ def upsert_row(conn, row: Row):
, rapid , rapid
, blitz , blitz
, bullet , bullet
, position
) )
VALUES VALUES
( %s ( %s
@ -140,6 +142,7 @@ def upsert_row(conn, row: Row):
, %s , %s
, %s , %s
, %s , %s
, %s
) )
ON CONFLICT ON CONFLICT
(site, username) (site, username)
@ -150,7 +153,8 @@ def upsert_row(conn, row: Row):
languages = EXCLUDED.languages, languages = EXCLUDED.languages,
rapid = EXCLUDED.rapid, rapid = EXCLUDED.rapid,
blitz = EXCLUDED.blitz, blitz = EXCLUDED.blitz,
bullet = EXCLUDED.bullet; bullet = EXCLUDED.bullet,
position = EXCLUDED.position;
""", """,
[ [
row["site"].value, row["site"].value,
@ -162,6 +166,7 @@ def upsert_row(conn, row: Row):
row.get("rapid"), row.get("rapid"),
row.get("blitz"), row.get("blitz"),
row.get("bullet"), row.get("bullet"),
random.randint(0, 1000000),
], ],
) )
conn.commit() conn.commit()

View File

@ -13,6 +13,7 @@ CREATE TABLE coach_scraper.export
, rapid INT , rapid INT
, blitz INT , blitz INT
, bullet INT , bullet INT
, position INT
); );
CREATE UNIQUE INDEX IF NOT EXISTS CREATE UNIQUE INDEX IF NOT EXISTS