Skip to content

Instantly share code, notes, and snippets.

@nackjicholson
Last active November 17, 2018 20:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nackjicholson/6388256a6e80991c36b404d677626e8d to your computer and use it in GitHub Desktop.
Save nackjicholson/6388256a6e80991c36b404d677626e8d to your computer and use it in GitHub Desktop.
Get the F1DB
brew install pgloader
brew install mysql@5.7
brew services start mysql@5.7
brew link mysql@5.7 --force

curl -LO http://ergast.com/downloads/f1db.sql.gz
gunzip -k f1db.sql.gz
msyql -uroot
> create database f1db;
> source f1db.sql
createdb f1db
pgloader mysql://root@localhost/f1db pgsql:///f1db
psql -d f1db
f1db# COPY (select distinct driverid, driverref, drivers.number, code, forename, surname, dob, nationality, drivers.url from drivers join results using(driverid) join races using(raceid) where raceid in (1008, 1007)) to '/Users/nackjicholson/Downloads/drivers.csv' csv header;
tail -n +2 drivers.csv > drivers_data.csv
sqlite3
sqlite> create table drivers (driverid integer not null primary key, driverref text not null, number integer not null, code text not null, forename text not null, surname text not null, dob date not null, nationality text not null, url text not null);
sqlite> .mode csv
sqlite> .import /Users/nackjicholson/Downloads/drivers_data.csv drivers
sqlite> select * from drivers;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment