Key (pos_team)=(JAX) is not present in table "team".
See original GitHub issueGetting 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:
- Created 7 years ago
- Comments:27 (1 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 insidenflgame
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).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')
Runnfldb-update
If you’d like, you can verify that only the
play
table needs to be updated: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'