Giter Club home page Giter Club logo

nfldb's Introduction

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".

nfldb's People

Contributors

burntsushi avatar derek-adair avatar ersherr avatar ochawkeye avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.