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
- Product Ideas
- 2.1K Ideas Exchange
- Data Connections
- 1.3K Connectors
- 309 Workbench
- 17 Cloud Integrations
- Data & ETL
- 2.3K Magic ETL
- 120 SQL DataFlows
- 666 Datasets
- Visualize & Apps
- 90 App Studio
- 198 Pro-code Components
- 2.6K Charting & Analyzer
- 873 Calculations & Variables (Beast Mode)
- AI & Data science
- 23 Domo AI & AI Chat
- 4 Managing AI
- 18 Jupyter Workspaces
- Automate
- 122 Workflows
- Alerts
- Distribute
- 118 Domo Everywhere
- 284 Reporting
- Manage
- 145 Governance & Security
- 489 APIs
- 11 Add-ins & Plugins
- 13 Domo Community Gallery
- 49 Product Releases
- 13 Domo University
- Community Forums
- 41 Getting Started
- 31 Community Member Introductions
- 118 Community Announcements
- 5K Archive