Skip to content
forked from BurntSushi/nfldb

A library to manage and update NFL data in a relational database.

License

Unlicense, Unknown licenses found

Licenses found

Unlicense
UNLICENSE
Unknown
COPYING
Notifications You must be signed in to change notification settings

derek-adair/nfldb

 
 

Repository files navigation

A MAINTAINED FORK OF ANDREW GALANTS NFLDB

nfldb is a relational database bundled with a Python module to quickly and conveniently query and update the database with data from active games. Data is imported from nflgame, which in turn gets its data from a JSON feed on NFL.com's live GameCenter pages. This data includes, but is not limited to, game schedules, scores, rosters and play-by-play data for every preseason, regular season and postseason game dating back to 2009.

Setup Docker Compose

  1. Clone this project
git clone https://github.com/derek-adair/nfldb.git && cd nfldb
  1. Download the latest DB from the release tab
export NFLDB_VERSION="1.0.0a4"
wget https://github.com/derek-adair/nfldb/releases/download/$NFLDB_VERSION/nfldb2019.sql.zip && \
    unzip nfldb2019.sql.zip
  1. Start Postgres & import the database (this can take a while...)
docker-compose up -d postgres
docker exec -i nfldb-postgres psql -U postgres -c "CREATE DATABASE nfldb;"
docker exec -i nfldb-postgres psql -U postgres nfldb < nfldb.sql
# cleanup
rm nfldb2019.sql.zip nfldb.sql
  1. Boot up a nfldb container
docker-compose run --rm nfldb
  1. Run some things
import nfldb

db = nfldb.connect()
q = nfldb.Query(db)

q.game(season_year=2019, season_type='Regular')
for pp in q.sort('passing_yds').limit(5).as_aggregate():
    print ( pp.player, pp.passing_yds )

And the output is:

Jameis Winston (NO, QB) 5109
Dak Prescott (DAL, QB) 4902
Jared Goff (LA, QB) 4638
Philip Rivers (IND, QB) 4615
Matt Ryan (ATL, QB) 4466

Documentation and getting help

comprehensive API documentation. Tutorials, more examples and a description of the data model can be found on the nfldb wiki.

If you need any help or have found a bug, please open a new issue on nfldb's issue tracker

OR come visit us in discord on channel https://discord.gg/G7uay2.

Installation and dependencies

nfldb depends on the following Python packages available in PyPI: nflgame, psycopg2, pytz and enum34.

Please see the installation guide on the nfldb wiki for instructions on how to setup nfldb.

Entity-relationship diagram

Here's a condensed version that excludes play and player statistics:

Shortened ER diagram for nfldb

There is also a full PDF version that includes every column in the database.

The nfldb wiki has a description of the data model.

Download the 2019 nfldb PostgreSQL database from your matching release here. They are attached under "assets".

About

A library to manage and update NFL data in a relational database.

Resources

License

Unlicense, Unknown licenses found

Licenses found

Unlicense
UNLICENSE
Unknown
COPYING

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 99.2%
  • Other 0.8%