APIs & Domo Developer

APIs & Domo Developer

with pydomo using DataSetClient data_export() to export dataset to string

  1. dataset = DataSetClient()
  2. include_csv_header = True
  3. datasets_parent = dataset.data_export(dataset_id, include_csv_header)
  4. # datasets_parent = self.pydomo.datasets.data_export(dataset_id, include_csv_header)
  5. logging.info(f'datasets_parent: {datasets_parent}')
  6. return datasets_parent
  7.  
  8.  
  9.  
  10. but I keep seeing missing 2 required positional arguments: 'transport' and 'logger'

but I don't see any info on what transport and logger is

Welcome!

It looks like you're new here. Members get access to exclusive content, events, rewards, and more. Sign in or register to get started.
Sign In

Comments

  • Logger is a python builtin logging.logger object. You can read the documentation on that object here: https://docs.python.org/3/library/logging.html

    transport is an instance of DomoAPITransport object: https://github.com/domoinc/domo-python-sdk/blob/dacdee87d9e798f4c83f270b38c8ea2b1b6c7923/pydomo/Transport.py#L8

    You need to pass in your transport and logger objects as the first and second parameter respectively when instantiating the DataSetClient object. https://github.com/domoinc/domo-python-sdk/blob/94c33af084427fcb03e1ebd6932e794ce9611188/pydomo/datasets/DataSetClient.py#L24

    **Was this post helpful? Click Agree or Like below**
    **Did this solve your problem? Accept it as a solution!**
  • Hi @GrantSmith , thanks for responding. The Transport bit is confusing me. Do I also have to call the DomoAPITransport class in order to call the DataSetClient?


    1. dataset = DataSetClient(transport=DomoAPITransport(client_id, client_secret, api_host, use_https, logger, request_timeout),
    2. logger =logger)
    3. include_csv_header = True
    4.  
    5. datasets_parent = dataset.data_export(dataset_id, include_csv_header)


  • @GrantSmith - Also, regarding the logger part, can you clarify more on what exactly to add for this parameter?

  • It's easiest to just instantiate a Domo object with your client ID and secret which will handle the transport object creation.

    Something like this:

    1. import logging # Logger object
    2.  
    3.  
    4. # My Domo Client ID and Secret (https://developer.domo.com/manage-clients)
    5. # Update these
    6. CLIENT_ID = 'MY_CLIENT_ID'
    7. CLIENT_SECRET = 'MY_CLIENT_SECRET'
    8.  
    9. # The Domo API host domain. This can be changed as needed - for use with a proxy or test environment
    10. API_HOST = 'api.domo.com'
    11.  
    12. handler = logging.StreamHandler()
    13. handler.setLevel(logging.INFO)
    14. formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
    15. handler.setFormatter(formatter)
    16. logging.getLogger().addHandler(handler)
    17. domo = Domo(client_id, client_secret, logger_name='foo', log_level=logging.INFO, api_host=API_HOST, **kwargs)
    18.  
    19. # Your code with one modification - you can access the DataSetClient from your Domo object:
    20. dataset = domo.dataset
    21.  
    22. include_csv_header = True
    23. datasets_parent = dataset.data_export(dataset_id, include_csv_header)
    24. # datasets_parent = self.pydomo.datasets.data_export(dataset_id, include_csv_header)
    25. logging.info(f'datasets_parent: {datasets_parent}')
    26. 


    **Was this post helpful? Click Agree or Like below**
    **Did this solve your problem? Accept it as a solution!**
  • hi @GrantSmith - when I try this I see the error:

    1. 'Domo' object has no attribute 'dataset'


  • Member
    edited November 2022

    Hi @GrantSmith - ignore that last message, I just needed to change it to "datasets" .


    But the dataset I'm trying to download is 257 million rows, and it seems to be timing out each time I try the code you had sent, is there a way to split it out into chunks perhaps within the code so this doesn't happen?

Welcome!

It looks like you're new here. Members get access to exclusive content, events, rewards, and more. Sign in or register to get started.
Sign In