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.8K Product Ideas
- 1.8K Ideas Exchange
- 1.6K Connect
- 1.2K Connectors
- 302 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 2.9K Transform
- 104 SQL DataFlows
- 633 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 760 Beast Mode
- 62 App Studio
- 42 Variables
- 699 Automate
- 181 Apps
- 457 APIs & Domo Developer
- 51 Workflows
- 10 DomoAI
- 38 Predict
- 16 Jupyter Workspaces
- 22 R & Python Tiles
- 401 Distribute
- 116 Domo Everywhere
- 277 Scheduled Reports
- 8 Software Integrations
- 130 Manage
- 127 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 12 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 111 Community Announcements
- 4.8K Archive