How to use query-data command of domo CLI

Hello all.
When using the domoCLI query-data command, there are --query and --queryfile command options.
I would like to know how to write a JSON-formatted query that can be used for each.
For example, what if you want to retrieve only the "Name" field from the following dataset.
[Example data set]
ID Name Address
1 John Minnesota
2 Robert Wisconsin
3 William Michigan
4 James New Jersey
5 Charles California
That's all. Thank you.
Best Answer
-
make sure to use the help command...
query-data -i <dataset_id> -xf <export_filename> -sql "SELECT AVG(avgHeartRate) AS heartRate, activityName FROM `{dataset_id}` WHERE avgHeartRate > 0 GROUP BY athleteId, month(startDate), year(startDate)"
usage:
-i,--id <ID> dataset id
-q,--query <QUERY> query
-qf,--queryfile <QUERYFILE> query filename
-sf,--sqlfile <SQLFILE> sql filename
-sql,--sql <SQL> sql query
-xf,--exportfile <EXPORTNAME> export filenamelooks like a SQL query would be -sql not -q.
I would put my SELECT statement into a csv file (myquery.sql) and then use the -sf flag
Jae Wilson
Check out my 🎥 Domo Training YouTube Channel 👨💻
**Say "Thanks" by clicking the ❤️ in the post that helped you.
**Please mark the post that solves your problem by clicking on "Accept as Solution"1
Answers
-
QueryFile will definitely be the easier b/c you don't have to worry about escaping single ticks ' in your SELECT statement.
Try
SELECT name FROM dataset_id
Jae Wilson
Check out my 🎥 Domo Training YouTube Channel 👨💻
**Say "Thanks" by clicking the ❤️ in the post that helped you.
**Please mark the post that solves your problem by clicking on "Accept as Solution"0 -
Thank you for your specific advice!
I tried the following command.
[Executed Command]
query-data -xf "C:test\export.csv" -i
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -q SELECT Name FROM xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxAnd the execution result is as follows.
[Result]
Unrecognized token 'SELECT': was expecting ('true', 'false' or 'null')
at [Source: (String)"SELECT"; line: 1, column: 13]Do you know what caused it?
I tried command variously, but it was the same.
For example...
query-data -xf "C:test\export.csv" -i
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -q SELECT Name FROM xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx;query-data -xf "C:test\export.csv" -i
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -q "SELECT Name FROM xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"query-data -xf "C:test\export.csv" -i
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -q "SELECT Name FROM xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx;"0 -
make sure to use the help command...
query-data -i <dataset_id> -xf <export_filename> -sql "SELECT AVG(avgHeartRate) AS heartRate, activityName FROM `{dataset_id}` WHERE avgHeartRate > 0 GROUP BY athleteId, month(startDate), year(startDate)"
usage:
-i,--id <ID> dataset id
-q,--query <QUERY> query
-qf,--queryfile <QUERYFILE> query filename
-sf,--sqlfile <SQLFILE> sql filename
-sql,--sql <SQL> sql query
-xf,--exportfile <EXPORTNAME> export filenamelooks like a SQL query would be -sql not -q.
I would put my SELECT statement into a csv file (myquery.sql) and then use the -sf flag
Jae Wilson
Check out my 🎥 Domo Training YouTube Channel 👨💻
**Say "Thanks" by clicking the ❤️ in the post that helped you.
**Please mark the post that solves your problem by clicking on "Accept as Solution"1 -
I was able to get the expected results.
I was making a misunderstanding.
Thank you for your advice.0
Categories
- All Categories
- 1.9K Product Ideas
- 1.9K Ideas Exchange
- 1.6K Connect
- 1.3K Connectors
- 306 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 3K Transform
- 112 SQL DataFlows
- 649 Datasets
- 2.2K Magic ETL
- 4K Visualize
- 2.5K Charting
- 787 Beast Mode
- 78 App Studio
- 43 Variables
- 742 Automate
- 187 Apps
- 474 APIs & Domo Developer
- 67 Workflows
- 14 DomoAI
- 40 Predict
- 17 Jupyter Workspaces
- 23 R & Python Tiles
- 406 Distribute
- 117 Domo Everywhere
- 279 Scheduled Reports
- 10 Software Integrations
- 139 Manage
- 136 Governance & Security
- 8 Domo Community Gallery
- 44 Product Releases
- 12 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 113 Community Announcements
- 4.8K Archive