0

My first ever program after hello world, lol.

I have managed to cobble the following together, and it works for my current purposes. But its very, very slow indeed.

I think that's because the program is looking at every single deal, and checks each record against the deal id.

Probably, the answer is to search for the deal, and only return that data. How do I go about changing the code to do this kind of search (that is, for the deal ID) and then only return that data?

Sorry for such an embarrassingly naive question!

from pypedriver import Client
pipedrive = Client('Pipedrive_API_key')
print('enter deal id')
input_deal_id = input()
print('deal id is set to ' + input_deal_id )
deals = pipedrive.Deal.fetch_all()
for deal in deals:
    if str(deal.id) == str(input_deal_id):
        print(deal.title, deal.id, deal.value, deal.currency)
  • 1
    the slowdown is probably not the checking everything, but rather the downloading everything with `pipedrive.Deal.fetch_all()`. It would be much better if you could do something like `pipedrive.Deal.fetch_by_id(input_deal_id)` where you only download the information you need. – Aaron Jun 01 '18 at 19:09
  • 1
    The underlying API allows for requesting a single deal by its ID; you might want to try using something like `requests` to use it directly, or another module (for example, python-pipedrive) which supports such calls. – Scott Hunter Jun 01 '18 at 19:14

0 Answers0