Skip to main content

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

Project description

Module nfldb provides command line tools and a library for maintaining and querying a relational database of play-by-play NFL data. The 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.

Here is a small teaser that shows how to use nfldb to find the top five passers in the 2012 regular season:

#!python
import nfldb

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

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

And the output is:

[andrew@Liger ~] python2 top-five.py
Drew Brees (NO, QB) 5177
Matthew Stafford (DET, QB) 4965
Tony Romo (DAL, QB) 4903
Tom Brady (NE, QB) 4799
Matt Ryan (ATL, QB) 4719

In theory, both nfldb and nflgame provide access to the same data. The difference is in the execution. In order to search data in nflgame, a large JSON file needs to be read from disk and loaded into Python data structures for each game. Conversely, nfldb’s data is stored in a relational database, which can be searched and retrieved faster than nflgame by a few orders of magnitude. Moreover, the relational organization of data in nfldb allows for a convenient query interface to search NFL play data.

The database can be updated with real time data from active games by running the nfldb-update script included with this module as often as you’re comfortable pinging NFL.com. (N.B. The JSON data itself only updates every 15 seconds, so running nfldb-update faster than that would be wasteful.) Roster updates are done automatically at a minimum interval of 12 hours.

nfldb has comprehensive API documentation and a wiki with examples.

nfldb can be used in conjunction with nflvid to search and watch NFL game footage.

If you need help, please join us at our IRC channel #nflgame on FreeNode.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nfldb-0.0.12.tar.gz (1.1 MB view details)

Uploaded Source

Built Distribution

nfldb-0.0.12.linux-x86_64.exe (1.2 MB view details)

Uploaded Source

File details

Details for the file nfldb-0.0.12.tar.gz.

File metadata

  • Download URL: nfldb-0.0.12.tar.gz
  • Upload date:
  • Size: 1.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for nfldb-0.0.12.tar.gz
Algorithm Hash digest
SHA256 47a857f9811a8e56e4e90d426acf46feeb6f8fb0be8a5c1f7395d69432cfa83a
MD5 c46e2c230ce2517185d3f3c7fe6e4043
BLAKE2b-256 1e3b09ba35cdc189e64ca7dbc20a7f1b4719e2d312fd49756caf71bc5f3eb581

See more details on using hashes here.

File details

Details for the file nfldb-0.0.12.linux-x86_64.exe.

File metadata

File hashes

Hashes for nfldb-0.0.12.linux-x86_64.exe
Algorithm Hash digest
SHA256 f9a21c7c9aa623592b96394d52bcecef63ac10dd12746ec6e60c711e257cb679
MD5 cb8941cd3883ec914d1edcf6cfba1c5a
BLAKE2b-256 3598d92467ef9c4e4eac06654ea80ef6a5a6e724f0f90a9973b02903d6106e51

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page