From 90b6da3fd9eece4ef2ecd3566cda5fb1cf8c612d Mon Sep 17 00:00:00 2001 From: filifa Date: Sat, 4 May 2024 21:16:35 -0500 Subject: [PATCH] more 2024 adjustments --- sql/homegames.sql | 10 +++++----- sql/parks.sql | 12 +++--------- sql/people.sql | 8 ++++++-- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/sql/homegames.sql b/sql/homegames.sql index d0d0fd6..6b4ba22 100644 --- a/sql/homegames.sql +++ b/sql/homegames.sql @@ -6,15 +6,15 @@ attach database 'baseball-raw.db' as 'raw'; create temp table homegames as select * from "raw".homegames; -alter table "homegames" drop column "league.key"; +alter table "homegames" drop column "leaguekey"; update homegames -set "team.key" = 'WS9' -where "team.key" = 'WAS' and "year.key" between 1891 and 1899; +set "teamkey" = 'WS9' +where "teamkey" = 'WAS' and "yearkey" between 1891 and 1899; update homegames -set "team.key" = 'PHP' -where "team.key" = 'PH4' and "year.key" between 1890 and 1891; +set "teamkey" = 'PHP' +where "teamkey" = 'PH4' and "yearkey" between 1890 and 1891; CREATE TABLE IF NOT EXISTS main."homegames" ( "year" NUMERIC, diff --git a/sql/parks.sql b/sql/parks.sql index 8db1f56..1100217 100644 --- a/sql/parks.sql +++ b/sql/parks.sql @@ -6,14 +6,8 @@ attach database 'baseball-raw.db' as 'raw'; create temp table parks as select * from "raw".parks; -alter table parks drop column "park.alias"; - --- insert some missing parks -insert into parks values -('ARL03', 'Globe Life Field', 'Arlington', 'TX', 'US'), -('BUF05', 'Sahlen Field', 'Buffalo', 'NY', 'US'), -('DUN01', 'TD Ballpark', 'Dunedin', 'FL', 'US'), -('DYE01', 'Field of Dreams', 'Dyersville', 'IA', 'US'); +alter table parks drop column "ID"; +alter table parks drop column "parkalias"; CREATE TABLE IF NOT EXISTS main."parks" ( "ID" TEXT, @@ -24,5 +18,5 @@ CREATE TABLE IF NOT EXISTS main."parks" ( PRIMARY KEY("ID") ); -insert into main.parks select distinct * from temp."parks"; +insert into main.parks select distinct "parkkey", "parkname", "city", "state", "country" from temp."parks"; commit; diff --git a/sql/people.sql b/sql/people.sql index 6cc2fa4..6b5b06a 100644 --- a/sql/people.sql +++ b/sql/people.sql @@ -6,12 +6,16 @@ attach database 'baseball-raw.db' as 'raw'; create temp table people as select * from "raw".people; +alter table people drop column "ID"; + -- insert some missing people insert into people values -('millema99', 1917, 4, 14, 'USA', 'NY', 'Brooklyn', 2012, 11, 27, 'USA', 'NY', 'Manhattan', 'Marvin', 'Miller', 'Marvin Julian', null, null, null, null, null, null, null, 'millema99'), ('fowlebu99', 1858, 3, 16, 'USA', 'NY', 'Fort Plain', 1913, 2, 26, 'USA', 'NY', 'Frankfort', 'Bud', 'Fowler', 'John W. Jackson', 155, 67, 'R', 'R', null, null, null, 'fowlebu99'), ('thompan01', null, null, null, null, null, null, null, null, null, null, null, null, null, 'Thompson', null, null, null, null, null, '1875-04-26', '1875-05-17', null, 'thompan01'); +delete from people +where playerID = 'kellyho99'; + update people set birthcountry = nullif(birthcountry, ''), @@ -61,9 +65,9 @@ CREATE TABLE main."people" ( "bats" text check ("bats" in ('L','R','B')), "throws" text check ("throws" in ('L','R','B')), "debut" text check (unixepoch("debut") <= unixepoch("finalGame")), + "bbrefID" text unique, "finalGame" text, "retroID" text unique, - "bbrefID" text unique, primary key("ID") );