Domo API to MS-SQL
I tried unsuccessfully to find an example of pulling a Domo dataset directly to MS-SQL via the API. So I created my own. I am not a python coder but my script works just fine. Does anyone have a version of this subroutine that does not require defining the column names (ie header)?
#Retrieve dataset from Domo API
def get_domo_dataset(dataset_id):
dataset_url = f'https://api.domo.com/v1/datasets/' + dataset_id + '/data'
headers = {'Authorization': f'Bearer {token}'}
response = requests.get(dataset_url, headers=headers)
if response.status_code == 200:
try:
data = response.content.decode('utf-8')
headers = 'field_1','field_2','field_3'
reader = csv.reader(io.StringIO(data))
dataset = [dict(zip(headers, row)) for row in reader]
return dataset
except csv.Error as e:
print('Failed to parse CSV data:', str(e))
return None
else:
print('Failed to retrieve dataset from Domo API:', response.text)
return None
** Was this post helpful? Click Agree or Like below. **
** Did this solve your problem? Accept it as a solution! **
Best Answer
-
@ArborRose - I have an idea for you that may make your life easier.
Domo has an ODBC driver. I'm betting you could install that on the machine your SQL server sits on then configure a linked server on the SQL Server side. That way, you can query and view Domo data live using standard MS SQL. I havent done it myself, but we used to use MS SQL before Domo and if some external datasource had ODBC drivers, we'd link them directly into our SQL Server to make it much easier on ourselves. We could then just schedule a SQL server job to select data out of a given source and upsert it into a SQL table.
ODBC Driver:
Creating a linked server in MSSQL to an ODBC datasource:
1
Answers
-
Just realized I already have a script that I use to export csv files - that pulls me the dataset with the headers.
** Was this post helpful? Click Agree or Like below. **
** Did this solve your problem? Accept it as a solution! **0 -
@ArborRose - I have an idea for you that may make your life easier.
Domo has an ODBC driver. I'm betting you could install that on the machine your SQL server sits on then configure a linked server on the SQL Server side. That way, you can query and view Domo data live using standard MS SQL. I havent done it myself, but we used to use MS SQL before Domo and if some external datasource had ODBC drivers, we'd link them directly into our SQL Server to make it much easier on ourselves. We could then just schedule a SQL server job to select data out of a given source and upsert it into a SQL table.
ODBC Driver:
Creating a linked server in MSSQL to an ODBC datasource:
1 -
@Domodork - I like the idea. I may use the ODBC driver at some point in the future. This API call is a special use case that we want to go through the API.
** Was this post helpful? Click Agree or Like below. **
** Did this solve your problem? Accept it as a solution! **0
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
- 754 Beast Mode
- 61 App Studio
- 41 Variables
- 693 Automate
- 178 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