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

dataset = DataSetClient()
include_csv_header = True
datasets_parent = dataset.data_export(dataset_id, include_csv_header)
# datasets_parent = self.pydomo.datasets.data_export(dataset_id, include_csv_header)
logging.info(f'datasets_parent: {datasets_parent}')
return datasets_parent



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

Comments

  • GrantSmith
    GrantSmith Indiana 🥷

    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?


    dataset = DataSetClient(transport=DomoAPITransport(client_id, client_secret, api_host, use_https, logger, request_timeout),
                            logger =logger)
    include_csv_header = True
    
    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?

  • GrantSmith
    GrantSmith Indiana 🥷

    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:

    import logging # Logger object
    
    
    # My Domo Client ID and Secret (https://developer.domo.com/manage-clients)
    # Update these
    CLIENT_ID = 'MY_CLIENT_ID'
    CLIENT_SECRET = 'MY_CLIENT_SECRET'
    
    # The Domo API host domain. This can be changed as needed - for use with a proxy or test environment
    API_HOST = 'api.domo.com'
    
    handler = logging.StreamHandler()
    handler.setLevel(logging.INFO)
    formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
    handler.setFormatter(formatter)
    logging.getLogger().addHandler(handler)
    domo = Domo(client_id, client_secret, logger_name='foo', log_level=logging.INFO, api_host=API_HOST, **kwargs)
    
    # Your code with one modification - you can access the DataSetClient from your Domo object:
    dataset = domo.dataset
    
    include_csv_header = True
    datasets_parent = dataset.data_export(dataset_id, include_csv_header)
    # datasets_parent = self.pydomo.datasets.data_export(dataset_id, include_csv_header)
    logging.info(f'datasets_parent: {datasets_parent}')
    
    


    **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:

    'Domo' object has no attribute 'dataset'
    


  • KristiKovacs
    KristiKovacs ⚪️
    edited November 7

    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?