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

setup help #231

Closed
hiramf opened this issue Mar 13, 2017 · 6 comments
Closed

setup help #231

hiramf opened this issue Mar 13, 2017 · 6 comments

Comments

@hiramf
Copy link

hiramf commented Mar 13, 2017

running on ubuntu 16.10, using IDLE(2)
everything seems to be installed correctly. however, i am not getting any info back from my queries. instead, I'm getting this:

>>>top-ten-qbs.py
(<nfldb.types.Player object at 0x7f3664d316c8>, 4952L)

So then I tried just the first command...

>>> nfldb.connect()
<connection object at 0x7f3664dcab48; dsn: 'port=5432 host=localhost 
password=xxxxxxxxx dbname=nfldb user=nfldb', closed: 0>
@leighlondon
Copy link

leighlondon commented Mar 13, 2017 via email

@ochawkeye
Copy link
Contributor

<connection object at 0x7f3664dcab48; dsn: 'port=5432 host=localhost password=xxxxxxxxx dbname=nfldb user=nfldb', closed: 0>

I'm not seeing a problem there. You're just not doing anything with your database connection.

Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import nfldb
>>> nfldb.connect()
<connection object at 0x027AC8B0; dsn: 'dbname=nfldb user=nfldb password=xxxxxx host=localhost port=5432', closed: 0>
>>> db = nfldb.connect()
>>> q = nfldb.Query(db)
>>> q.game(season_year=2016, season_type='Regular', week=3)
<nfldb.query.Query object at 0x02873290>
>>> for game in q.as_games():
	print game

	
Regular 2016 week 3 on 09/25 at 03:05PM, LA (37) at TB (32)
Regular 2016 week 3 on 09/25 at 03:25PM, PIT (3) at PHI (34)
Regular 2016 week 3 on 09/25 at 03:25PM, SD (22) at IND (26)
Regular 2016 week 3 on 09/25 at 03:25PM, NYJ (3) at KC (24)
Regular 2016 week 3 on 09/25 at 07:30PM, CHI (17) at DAL (31)
Regular 2016 week 3 on 09/26 at 07:30PM, ATL (45) at NO (32)
Regular 2016 week 3 on 09/22 at 07:25PM, HOU (0) at NE (27)
Regular 2016 week 3 on 09/25 at 12:00PM, ARI (18) at BUF (33)
Regular 2016 week 3 on 09/25 at 12:00PM, MIN (22) at CAR (10)
Regular 2016 week 3 on 09/25 at 12:00PM, DEN (29) at CIN (17)
Regular 2016 week 3 on 09/25 at 12:00PM, DET (27) at GB (34)
Regular 2016 week 3 on 09/25 at 12:00PM, BAL (19) at JAC (17)
Regular 2016 week 3 on 09/25 at 12:00PM, CLE (24) at MIA (30)
Regular 2016 week 3 on 09/25 at 12:00PM, WAS (29) at NYG (27)
Regular 2016 week 3 on 09/25 at 12:00PM, OAK (17) at TEN (10)
Regular 2016 week 3 on 09/25 at 03:05PM, SF (18) at SEA (37)
>>> 

@ochawkeye
Copy link
Contributor

I kind of answered these out of order...

top-ten-qbs.py

You don't run a .py file from within IDLE. From a command prompt or terminal window, you can enter python top-ten-qbs.py to execute that Python script. In *nix world, you can omit the python in python top-ten-qbs.py if you have a #shebang line at the top of the script.

@hiramf
Copy link
Author

hiramf commented Mar 13, 2017

here's my script:

import nfldb

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

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

for clarity, I'm writing in IDLE and hitting F5 to run.

also...when trying to run the .py from terminal, it's not finding the 'nfldb' module, but when I 'import nfldb' in terminal, i don't get an error.

@ochawkeye
Copy link
Contributor

I don't know enough about the __str__ representations of the nfldb types, but it appears that tuple you're printing is messing with what gets displayed?

image

@hiramf
Copy link
Author

hiramf commented Mar 13, 2017

@ochawkeye
those parentheses! wow. that fixed it. thank you.

@hiramf hiramf closed this as completed Mar 13, 2017
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

3 participants