2024-02-01 04:43:23 +00:00
|
|
|
pragma foreign_keys = 0;
|
|
|
|
|
2024-01-26 19:27:58 +00:00
|
|
|
begin;
|
2024-01-31 06:09:39 +00:00
|
|
|
attach database 'baseball-raw.db' as 'raw';
|
|
|
|
|
|
|
|
create temp table appearances as
|
|
|
|
select * from "raw".appearances;
|
|
|
|
|
|
|
|
alter table appearances drop column "lgID";
|
2024-01-28 04:53:07 +00:00
|
|
|
|
|
|
|
update appearances
|
|
|
|
set teamid = 'WS9'
|
|
|
|
where teamid = 'WAS' and yearid between 1891 and 1899;
|
|
|
|
|
|
|
|
update appearances
|
|
|
|
set teamid = 'PHP'
|
|
|
|
where teamid = 'PH4' and yearid between 1890 and 1891;
|
2024-01-31 06:09:39 +00:00
|
|
|
|
2024-02-01 04:37:26 +00:00
|
|
|
-- got this missing data from bbref
|
|
|
|
insert into appearances values
|
|
|
|
(1896,'BRO','dailyco01',1,null,1,null,0,1,0,0,0,0,0,0,0,0,0,null,null),
|
|
|
|
(1875,'WS6','thompfr01',11,null,11,null,0,11,0,0,0,0,0,0,1,1,0,null,null);
|
|
|
|
|
2024-01-31 06:09:39 +00:00
|
|
|
CREATE TABLE IF NOT EXISTS "appearances" (
|
|
|
|
"year" NUMERIC,
|
|
|
|
"team" TEXT,
|
|
|
|
"player" TEXT,
|
|
|
|
"G_all" NUMERIC,
|
|
|
|
"GS" NUMERIC,
|
|
|
|
"G_batting" NUMERIC,
|
|
|
|
"G_defense" NUMERIC,
|
|
|
|
"G_p" NUMERIC,
|
|
|
|
"G_c" NUMERIC,
|
|
|
|
"G_1b" NUMERIC,
|
|
|
|
"G_2b" NUMERIC,
|
|
|
|
"G_3b" NUMERIC,
|
|
|
|
"G_ss" NUMERIC,
|
|
|
|
"G_lf" NUMERIC,
|
|
|
|
"G_cf" NUMERIC,
|
|
|
|
"G_rf" NUMERIC,
|
|
|
|
"G_of" NUMERIC,
|
|
|
|
"G_dh" NUMERIC,
|
|
|
|
"G_ph" NUMERIC,
|
|
|
|
"G_pr" NUMERIC,
|
|
|
|
PRIMARY KEY("year","team","player"),
|
|
|
|
foreign key("player") references "people"("ID"),
|
|
|
|
foreign key("year","team") references "teamseasons"("year","team")
|
|
|
|
);
|
|
|
|
|
|
|
|
insert into main.appearances select distinct * from temp.appearances;
|
2024-01-26 19:27:58 +00:00
|
|
|
commit;
|