begin restucturing build

This commit is contained in:
Nick Griffey 2024-01-27 16:42:08 -06:00
parent 24c7faed1f
commit 1e249f62ce
3 changed files with 64 additions and 65 deletions

View File

@ -4,37 +4,37 @@ bbdb = baseballdatabank-2023.1
db: baseball.db db: baseball.db
baseball.db: sql/corrections/*.sql sql/keys/*.sql sql/1nf/*.sql sql/2nf/*.sql baseball.db: baseball-raw.db
rm -f baseball.db rm -f baseball.db
sqlite3 baseball.db ".import --csv $(bbdb)/core/AllstarFull.csv allstarfull" cat sql/people.sql | sqlite3 baseball.db
sqlite3 baseball.db ".import --csv $(bbdb)/core/Appearances.csv appearances"
sqlite3 baseball.db ".import --csv $(bbdb)/core/Batting.csv batting"
sqlite3 baseball.db ".import --csv $(bbdb)/core/BattingPost.csv battingpost"
sqlite3 baseball.db ".import --csv $(bbdb)/core/Fielding.csv fielding"
sqlite3 baseball.db ".import --csv $(bbdb)/core/FieldingOF.csv fieldingof"
sqlite3 baseball.db ".import --csv $(bbdb)/core/FieldingOFsplit.csv fieldingofsplit"
sqlite3 baseball.db ".import --csv $(bbdb)/core/FieldingPost.csv fieldingpost"
sqlite3 baseball.db ".import --csv $(bbdb)/core/HomeGames.csv homegames"
sqlite3 baseball.db ".import --csv $(bbdb)/core/Managers.csv managers"
sqlite3 baseball.db ".import --csv $(bbdb)/core/ManagersHalf.csv managershalf"
sqlite3 baseball.db ".import --csv $(bbdb)/core/Parks.csv parks"
sqlite3 baseball.db ".import --csv $(bbdb)/core/People.csv people"
sqlite3 baseball.db ".import --csv $(bbdb)/core/Pitching.csv pitching"
sqlite3 baseball.db ".import --csv $(bbdb)/core/PitchingPost.csv pitchingpost"
sqlite3 baseball.db ".import --csv $(bbdb)/core/SeriesPost.csv seriespost"
sqlite3 baseball.db ".import --csv $(bbdb)/core/Teams.csv teams"
sqlite3 baseball.db ".import --csv $(bbdb)/core/TeamsFranchises.csv teamsfranchises"
sqlite3 baseball.db ".import --csv $(bbdb)/core/TeamsHalf.csv teamshalf"
sqlite3 baseball.db ".import --csv $(bbdb)/contrib/AwardsManagers.csv awardsmanagers"
sqlite3 baseball.db ".import --csv $(bbdb)/contrib/AwardsPlayers.csv awardsplayers"
sqlite3 baseball.db ".import --csv $(bbdb)/contrib/AwardsShareManagers.csv awardssharemanagers"
sqlite3 baseball.db ".import --csv $(bbdb)/contrib/AwardsSharePlayers.csv awardsshareplayers"
sqlite3 baseball.db ".import --csv $(bbdb)/contrib/CollegePlaying.csv collegeplaying"
sqlite3 baseball.db ".import --csv $(bbdb)/contrib/HallOfFame.csv halloffame"
sqlite3 baseball.db ".import --csv $(bbdb)/contrib/Salaries.csv salaries"
sqlite3 baseball.db ".import --csv $(bbdb)/contrib/Schools.csv schools"
cat sql/corrections/*.sql | sqlite3 baseball.db
cat sql/keys/*.sql | sqlite3 baseball.db
cat sql/1nf/*.sql | sqlite3 baseball.db
cat sql/2nf/*.sql | sqlite3 baseball.db
sqlite3 baseball.db "VACUUM" sqlite3 baseball.db "VACUUM"
baseball-raw.db:
rm -f baseball-raw.db
sqlite3 baseball-raw.db ".import --csv $(bbdb)/core/AllstarFull.csv allstarfull"
sqlite3 baseball-raw.db ".import --csv $(bbdb)/core/Appearances.csv appearances"
sqlite3 baseball-raw.db ".import --csv $(bbdb)/core/Batting.csv batting"
sqlite3 baseball-raw.db ".import --csv $(bbdb)/core/BattingPost.csv battingpost"
sqlite3 baseball-raw.db ".import --csv $(bbdb)/core/Fielding.csv fielding"
sqlite3 baseball-raw.db ".import --csv $(bbdb)/core/FieldingOF.csv fieldingof"
sqlite3 baseball-raw.db ".import --csv $(bbdb)/core/FieldingOFsplit.csv fieldingofsplit"
sqlite3 baseball-raw.db ".import --csv $(bbdb)/core/FieldingPost.csv fieldingpost"
sqlite3 baseball-raw.db ".import --csv $(bbdb)/core/HomeGames.csv homegames"
sqlite3 baseball-raw.db ".import --csv $(bbdb)/core/Managers.csv managers"
sqlite3 baseball-raw.db ".import --csv $(bbdb)/core/ManagersHalf.csv managershalf"
sqlite3 baseball-raw.db ".import --csv $(bbdb)/core/Parks.csv parks"
sqlite3 baseball-raw.db ".import --csv $(bbdb)/core/People.csv people"
sqlite3 baseball-raw.db ".import --csv $(bbdb)/core/Pitching.csv pitching"
sqlite3 baseball-raw.db ".import --csv $(bbdb)/core/PitchingPost.csv pitchingpost"
sqlite3 baseball-raw.db ".import --csv $(bbdb)/core/SeriesPost.csv seriespost"
sqlite3 baseball-raw.db ".import --csv $(bbdb)/core/Teams.csv teams"
sqlite3 baseball-raw.db ".import --csv $(bbdb)/core/TeamsFranchises.csv teamsfranchises"
sqlite3 baseball-raw.db ".import --csv $(bbdb)/core/TeamsHalf.csv teamshalf"
sqlite3 baseball-raw.db ".import --csv $(bbdb)/contrib/AwardsManagers.csv awardsmanagers"
sqlite3 baseball-raw.db ".import --csv $(bbdb)/contrib/AwardsPlayers.csv awardsplayers"
sqlite3 baseball-raw.db ".import --csv $(bbdb)/contrib/AwardsShareManagers.csv awardssharemanagers"
sqlite3 baseball-raw.db ".import --csv $(bbdb)/contrib/AwardsSharePlayers.csv awardsshareplayers"
sqlite3 baseball-raw.db ".import --csv $(bbdb)/contrib/CollegePlaying.csv collegeplaying"
sqlite3 baseball-raw.db ".import --csv $(bbdb)/contrib/HallOfFame.csv halloffame"
sqlite3 baseball-raw.db ".import --csv $(bbdb)/contrib/Salaries.csv salaries"
sqlite3 baseball-raw.db ".import --csv $(bbdb)/contrib/Schools.csv schools"

View File

@ -1,33 +0,0 @@
BEGIN;
CREATE TABLE "pk_people" (
"playerID" NUMERIC,
"birthYear" NUMERIC,
"birthMonth" NUMERIC,
"birthDay" NUMERIC,
"birthCountry" NUMERIC,
"birthState" NUMERIC,
"birthCity" NUMERIC,
"deathYear" NUMERIC,
"deathMonth" NUMERIC,
"deathDay" NUMERIC,
"deathCountry" NUMERIC,
"deathState" NUMERIC,
"deathCity" NUMERIC,
"nameFirst" NUMERIC,
"nameLast" NUMERIC,
"nameGiven" NUMERIC,
"weight" NUMERIC,
"height" NUMERIC,
"bats" NUMERIC,
"throws" NUMERIC,
"debut" NUMERIC,
"finalGame" NUMERIC,
"retroID" NUMERIC,
"bbrefID" NUMERIC,
primary key("playerID")
);
INSERT INTO "pk_people" SELECT DISTINCT * FROM "people";
DROP TABLE "people";
ALTER TABLE "pk_people" RENAME TO "people";
COMMIT;

32
sql/people.sql Normal file
View File

@ -0,0 +1,32 @@
BEGIN;
attach database 'baseball-raw.db' as 'raw';
CREATE TABLE "people" (
"playerID" text,
"birthYear" NUMERIC,
"birthMonth" NUMERIC,
"birthDay" NUMERIC,
"birthCountry" text,
"birthState" text,
"birthCity" text,
"deathYear" text,
"deathMonth" text,
"deathDay" text,
"deathCountry" text,
"deathState" text,
"deathCity" text,
"nameFirst" text,
"nameLast" text,
"nameGiven" text,
"weight" NUMERIC,
"height" NUMERIC,
"bats" text,
"throws" text,
"debut" text,
"finalGame" text,
"retroID" text,
"bbrefID" text,
primary key("playerID")
);
INSERT INTO "people" SELECT DISTINCT * FROM "raw"."people";
COMMIT;