question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Key (pos_team)=(JAX) is not present in table "team".

See original GitHub issue

Getting the following from nfldb-update. TIA, PLA

/usr/local/bin/nfldb-update

-------------------------------------------------------------------------------

STARTING NFLDB UPDATE AT 2016-09-18 17:56:02.147214

Connecting to nfldb... done.

Setting timezone to UTC... done.

Locking write access to tables... done.

Updating season phase, year and week... done.

Bulk inserting data for 2 games...

Sending batch of data to database.

Traceback (most recent call last):

File "/usr/local/bin/nfldb-update", line 39, in <module>
nfldb.update.run(**vars(args))

File "/usr/local/lib/python2.7/dist-packages/nfldb/update.py", line 535, in run
doit()

File "/usr/local/lib/python2.7/dist-packages/nfldb/update.py", line 525, in doit
update_games(db, batch_size=batch_size)

File "/usr/local/lib/python2.7/dist-packages/nfldb/update.py", line 397, in update_games
bulk_insert_game_data(cursor, scheduled, batch_size=batch_size)

File "/usr/local/lib/python2.7/dist-packages/nfldb/update.py", line 221, in bulk_insert_game_data
do()

File "/usr/local/lib/python2.7/dist-packages/nfldb/update.py", line 188, in do
nfldb.db._big_insert(cursor, table, bulk[table])

File "/usr/local/lib/python2.7/dist-packages/nfldb/db.py", line 356, in _big_insert
% (table, insert_fields, values))

File "/usr/local/lib/python2.7/dist-packages/psycopg2/extras.py", line 223, in execute
return super(RealDictCursor, self).execute(query, vars)

psycopg2.IntegrityError: insert or update on table "play" violates foreign key constraint "play_pos_team_fkey"

DETAIL:  Key (pos_team)=(JAX) is not present in table "team".

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:27 (1 by maintainers)

github_iconTop GitHub Comments

15reactions
BurntSushicommented, Sep 20, 2016

I hope to have this fixed before the next game.

I think the best thing to do is to settle on JAC/JAX, and do the translation inside nflgame when the JSON is parsed. On the next update, I’ll include a DB migration that syncs the entire database with the correct team name (something similar to what @mlloyd5 did manually).

14reactions
mlloyd5commented, Sep 20, 2016

Ok so here’s my workaround. I reset my install, but I didn’t like the idea of keeping that inserted row in the teams table so I changed all occurrences of ‘JAX’ in the database to ‘JAC’ and then deleted the row from the teams table. Queries below: Run on the database: insert into team values ('JAX','Jacksonville','Jaguars') Run nfldb-update

If you’d like, you can verify that only the play table needs to be updated:

SELECT COUNT(*) from play where pos_team = 'JAX';
SELECT COUNT(*) from drive where pos_team = 'JAX';
SELECT COUNT(*) from game where home_team = 'JAX';
SELECT COUNT(*) from game where away_team = 'JAX';
SELECT COUNT(*) from player where team = 'JAX';
SELECT COUNT(*) from play_player where team = 'JAX';

Update play table: UPDATE play SET pos_team = 'JAC' WHERE pos_team = 'JAX'

Delete ‘JAX’ value from team: DELETE FROM team WHERE team_id = 'JAX'

Read more comments on GitHub >

github_iconTop Results From Across the Web

postgres key is not present in table constraint
The error message simply states that there is at least one row in the table product_template that contains the value 12 in the...
Read more >
Guide for the Care and Use of Laboratory Animals | OLAW - NIH
or specific emphases for agricultural animals and nontraditional species are presented. The Guide does not address in detail agricultural ani-.
Read more >
Guidelines for the housing of mice in scientific institutions
There are situations, for example studies involving highly aggressive strains, where group housing is not suitable. 3.1.3 Pair housing of male mice is...
Read more >
PostgreSQL - insert/update violates foreign key constraints
ERROR: insert or update on table "Table3" violates foreign key constraint "Table3_DataID_fkey" DETAIL: Key (DataID)=(27856) is not present ...
Read more >
47 CFR Part 90 -- Private Land Mobile Radio Services
(c) Part 2 contains the table of frequency allocations and special requirements in ... to mobile and base stations but are not employed...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found