Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL Examples Won't Work #168

Open
hassnkhan opened this issue Jul 30, 2016 · 1 comment
Open

SQL Examples Won't Work #168

hassnkhan opened this issue Jul 30, 2016 · 1 comment

Comments

@hassnkhan
Copy link

I'm trying to use the SQL examples from the Wiki and get the following errors, did something in the API change that I'm missing?

Using the example from the Wiki (below),

`query = '''
SELECT
play_player.player_id, SUM(play_player.passing_yds) AS passing_yds
FROM play_player
LEFT JOIN game ON play_player.gsis_id = game.gsis_id
WHERE game.season_type = 'Regular' AND game.season_year = 2012
GROUP BY play_player.player_id
ORDER BY passing_yds DESC LIMIT 5
'''
players = []
with nfldb.Tx(db) as cursor:
cursor.execute(query)
for row in cursor.fetchall():
pp = nfldb.PlayPlayer(db, None, None, None, row['player_id'],
None, row)
players.append(pp)

for pp in players:
print pp.player_id, pp.passing_yds`

Returns the following:


TypeError Traceback (most recent call last)
in ()
13 for row in cursor.fetchall():
14 pp = nfldb.PlayPlayer(db, None, None, None, row['player_id'],
---> 15 None, row)
16 players.append(pp)
17

TypeError: init() takes exactly 2 arguments (8 given)

@BurntSushi
Copy link
Owner

Hmm, yeah, it appears so. You might try calling nfldb.PlayPlayer.from_row_tuple(db, row) or nfldb.PlayPlayer.from_row_dict(db, row) instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants