Using Python API to Update Already Created Datasets

ElliotGitter
ElliotGitter Member
edited June 2022 in APIs & Domo Developer

Hi Everyone,


I am trying to find a way to upload information from a python script into a domo dataset weekly. I am finding that you can't update an existing dataset with this method, only create a new one and update that newly created one. Has anyone found a workaround for this? In the documentation it appears this is correct but it feels like this would be a necessary part of the API. The process would look something like, python runs a process to obtain a new pandas df. This df then needs to be loaded into an existing domo dataset. When I try using ds_update on a dataset that has already been created, I get a "Error retrieving DataSet: {"status":403,"statusReason":"Forbidden","message":"Access is denied"


Here is the documentation where it says, 'ds_update - updates an existing data set, only data sets created by the API can be updated'



Any help would be awesome, thanks! I'd rather not post this to SQL, then ingest from SQL to DOMO (no need to add steps if there is an API..)

Tagged:

Best Answers

  • mhouston
    mhouston Contributor
    Answer ✓

    @ElliotGitter where is your dataset coming from? Is it updating from somewhere else too?

    Once you've created the dataset using the API, you can always update it using the API (it's not like everytime you run your python script you have to create a new dataset to update). If you can create a new dataset using the API, update it once with the data in yourcurrent dataset, then moving forward you can update that dataset you created with your python script.

  • ElliotGitter
    ElliotGitter Member
    Answer ✓

    Hi @mhouston ,

    I just figured it out. I was using the ds_update() function with a variable that had already called the ID which may have been messing with the update. Here is the test case I was running before creating it for my use case.

    Here is the old way which was giving me the 403 error:

    testdata = domo.ds_get('myid')

    test2 = testdata.append(testdata).reset_index(drop=True)

    update = domo.ds_update(testdata, test2)


    Here is the new way (call the Dataset ID in the function instead of a variable that is holding the ID):

    update = domo.ds_update('myid', test2)

  • mhouston
    mhouston Contributor
    Answer ✓

    @ElliotGitter it looks like in your old way you weren't actually using the id in your ds_update function - reading your code it looks like testdata is a dataframe (ds_get returns a dataframe, not an id), and that's why you were getting an error.

Answers

  • mhouston
    mhouston Contributor
    Answer ✓

    @ElliotGitter where is your dataset coming from? Is it updating from somewhere else too?

    Once you've created the dataset using the API, you can always update it using the API (it's not like everytime you run your python script you have to create a new dataset to update). If you can create a new dataset using the API, update it once with the data in yourcurrent dataset, then moving forward you can update that dataset you created with your python script.

  • ElliotGitter
    ElliotGitter Member
    Answer ✓

    Hi @mhouston ,

    I just figured it out. I was using the ds_update() function with a variable that had already called the ID which may have been messing with the update. Here is the test case I was running before creating it for my use case.

    Here is the old way which was giving me the 403 error:

    testdata = domo.ds_get('myid')

    test2 = testdata.append(testdata).reset_index(drop=True)

    update = domo.ds_update(testdata, test2)


    Here is the new way (call the Dataset ID in the function instead of a variable that is holding the ID):

    update = domo.ds_update('myid', test2)

  • mhouston
    mhouston Contributor
    Answer ✓

    @ElliotGitter it looks like in your old way you weren't actually using the id in your ds_update function - reading your code it looks like testdata is a dataframe (ds_get returns a dataframe, not an id), and that's why you were getting an error.

  • Anyway that we could update the name and descriptions of the existing dataset? I checked that ds_rename and ds_import are not available now. Thanks.