mattdeboard / python-usdol

Python wrapper for US Dept. of Labor API
8 stars 3 forks source link

Problem with the _get_querystring function #2

Closed punkdata closed 11 years ago

punkdata commented 11 years ago

I tried using your mod and I get this error when executing thew fetchdata fucntion: data = conn.fetch_data('Safety/Fatalities','OSHA_Fatalities', orderby = 'id desc', top = 10, skip = 10)

Traceback (most recent call last): File "jfile.py", line 33, in data = conn.fetch_data('Safety/Fatalities','OSHA_Fatalities', orderby = 'id desc', top = 10, skip = 10) File "/home/angel/projects/govdata/python_usdol.py", line 124, in fetchdata orderby=orderby, filter=filter_) File "/home/angel/projects/govdata/python_usdol.py", line 96, in _get_querystring val = kwargs[arg].replace(' ', '+') AttributeError: 'int' object has no attribute 'replace'

Any ideas on how to fix this?

mattdeboard commented 11 years ago

Yeah make it top="10", skip="10"

I suppose I should do a type check there given the nature of those attributes.

mattdeboard commented 11 years ago

This isn't really a bug but it's pretty natural to pass these parameters as integers, so adding type coercion to the _get_querystring method seems like a good idea. Fixed this up in 348a24d91f7, might want to pull again.

punkdata commented 11 years ago

Hi did a git pull and I enclosed the values in double quotes and now I get this as the error.

Traceback (most recent call last): File "jfile.py", line 35, in data = conn.fetch_data('Safety/Fatalities', 'OSHA_Fatalities', top="2", skip="30") File "/home/angel/projects/govdata/python_usdol.py", line 136, in fetch_data ret = d.get('results', d) AttributeError: 'list' object has no attribute 'get'

Any ideas for a fix? thx

mattdeboard commented 11 years ago

The only thing I can think of is that maybe US DOL changed their API? Dunno why you'd get a list instead of a dictionary. What data are you getting back?

On Wed, Oct 17, 2012 at 12:02 AM, ariv3ra notifications@github.com wrote:

Hi did a git pull and I enclosed the values in double quotes and now I get this as the error.

Traceback (most recent call last): File "jfile.py", line 35, in data = conn.fetch_data('Safety/Fatalities', 'OSHA_Fatalities', top="2", skip="30") File "/home/angel/projects/govdata/python_usdol.py", line 136, in fetch_data ret = d.get('results', d) AttributeError: 'list' object has no attribute 'get'

Any ideas for a fix? thx

— Reply to this email directly or view it on GitHubhttps://github.com/mattdeboard/python-usdol/issues/2#issuecomment-9515392.