Trigger a dataset update via python using a post call
I am currently successfully triggering a dataset update from Snowflake to Domo via python using the following code:
import requests
#list of dataset ids and stream ids for the Snowflake>Domo connections guids = { 'datasetID': 'StreamID', 'DatasetID2': 'StreamID2', }
#Does the work of kicking off updates for all Domo datasets linked to Snowflake
domo_token = 'xxxxx' headers = {'x-domo-developer-token': domo_token}
for i in guids: url = f'https://domain.domo.com/api/data/v1/streams/{guids[i]}/executions' r = requests.post(url, headers=headers)
The problem is that this is legacy code and so I'm trying to determine how the original developers set this up. I know the dataset ID is in the dataset URL, but I'm not sure how to get a streamID, or set up a stream if necessary that works by executing a snowflake query.
Does anyone know how to set something like the above up where you can trigger the execution of a dataset via the stream api?
For reference, I found some documentation from domo on streams but it's a little too bare to put into action.
Best Answer
-
I was able to figure this out. In case anyone needs it:
from pydomo import Domo from pprint import pprint domo = Domo(client_id, client_secret, api_host=api_host) dataset_id = xxxx streams = domo.streamsstream_list = streams.list(2000,0)
dataset_streams = [stream for stream in stream_list if stream['dataSet']['id'] == dataset_id]dataset_stream = dataset_streams[0]
pprint(dataset_stream)
dataset_stream_id = dataset_stream['id']
streams.create_execution(dataset_stream_id) print(dataset_stream_id )2
Answers
-
I was able to figure this out. In case anyone needs it:
from pydomo import Domo from pprint import pprint domo = Domo(client_id, client_secret, api_host=api_host) dataset_id = xxxx streams = domo.streamsstream_list = streams.list(2000,0)
dataset_streams = [stream for stream in stream_list if stream['dataSet']['id'] == dataset_id]dataset_stream = dataset_streams[0]
pprint(dataset_stream)
dataset_stream_id = dataset_stream['id']
streams.create_execution(dataset_stream_id) print(dataset_stream_id )2 -
Beat me to it as I was going to suggest pydomo to do this. Here’s more documentation for future users https://github.com/domoinc/domo-python-sdk/blob/master/examples/stream.py
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**2
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.6K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 2.9K Transform
- 102 SQL DataFlows
- 626 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 753 Beast Mode
- 61 App Studio
- 41 Variables
- 692 Automate
- 177 Apps
- 456 APIs & Domo Developer
- 49 Workflows
- 10 DomoAI
- 38 Predict
- 16 Jupyter Workspaces
- 22 R & Python Tiles
- 398 Distribute
- 115 Domo Everywhere
- 276 Scheduled Reports
- 7 Software Integrations
- 130 Manage
- 127 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 11 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 110 Community Announcements
- 4.8K Archive