IBM Cloudant is connected to Jupyter notebook. I can work with database which is not very big. But when I want to get a data from the database which has many data, I get this error:
HTTPError: 429 Client Error: Too Many Requests too_many_requests You've exceeded your current limit of 5 requests per second for query class. Please try later
Is there anything to do for this problem? Any idea will be really helpful.
here is my code:
from cloudant.client import Cloudant
from cloudant.error import CloudantException
from cloudant.result import Result, ResultByKey
import cloudant
import pandas as pd
import json
serviceUsername = "x"
servicePassword = "y"
serviceURL = "z"
client = Cloudant(serviceUsername, servicePassword, url=serviceURL)
client.connect()
database1 = client['comfort']
userID= input("what is your user ID?")
for item in database1:
if userID == 'user_id':
print(item)
and here is what I get
what is your user ID?ss
> HTTPError Traceback (most recent call
> last)
> <ipython-input-7-98e9b2d333f5> in <module>()
> 4 userID= input("what is your user ID?")
> 5
> ----> 6 for item in database1:
> 7 if userID == 'user_id':
> 8 print(item)
>
> ~\Anaconda3\lib\site-packages\cloudant\database.py in __iter__(self, remote)
> 634 # next_startkey
> 635 include_docs=True,
> --> 636 startkey=next_startkey
> 637 ).get('rows', [])
> 638
>
> ~\Anaconda3\lib\site-packages\cloudant\database.py in all_docs(self, **kwargs)
> 391 '/'.join([self.database_url, '_all_docs']),
> 392 self.client.encoder,
> --> 393 **kwargs)
> 394 return resp.json()
> 395
>
> ~\Anaconda3\lib\site-packages\cloudant\_common_util.py in get_docs(r_session, url, encoder, headers, **params)
> 263 else:
> 264 resp = r_session.get(url, headers=headers, params=f_params)
> --> 265 resp.raise_for_status()
> 266 return resp
> 267
>
> ~\Anaconda3\lib\site-packages\requests\models.py in raise_for_status(self)
> 933
> 934 if http_error_msg:
> --> 935 raise HTTPError(http_error_msg, response=self)
> 936
> 937 def close(self):
>
> HTTPError: 429 Client Error: Too Many Requests too_many_requests You've exceeded your current limit of 5 requests per second for query
> class. Please try later. for url:
> https://2b5a4b.......
Try querying like this:
database1 = client['comfort']
userID= input("what is your user ID?")
selector = {'user_id': {'$eq': userID}}
docs = database1.get_query_result(selector)
for doc in docs:
do stuff...
Got this straight from the docs