Skip to content

querySimple ​

Command: querySimple
Category: Developer Tools
Status: Production Ready

Description ​

Execute a simple SQL query and display or export the results. This command provides a quick way to run SQL queries against the database with output options including table display, JSON, Excel, or CSV formats. Results can be saved to a file or displayed in the terminal.

Syntax ​

bash
hana-cli querySimple [options]

Aliases ​

  • qs
  • querysimple

Command Diagram ​

Parameters ​

Options ​

OptionAliasTypeDefaultDescription
--query-qstring-SQL query to execute
--folder-fstring./Folder path for output file (when saving to file)
--filename-nstring-Output filename (when saving to file)
--output-ostringtableOutput format. Choices: table, json, excel, csv
--profile-pstring-CDS Profile for connection

Connection Parameters ​

OptionAliasTypeDefaultDescription
--admin-abooleanfalseConnect via admin (default-env-admin.json)
--conn-string-Connection filename to override default-env.json

Troubleshooting ​

OptionAliasTypeDefaultDescription
--disableVerbose--quietbooleanfalseDisable verbose output - removes all extra output that is only helpful to human readable interface
--debug-dbooleanfalseDebug hana-cli itself by adding output of LOTS of intermediate details

Examples ​

Basic Usage ​

bash
hana-cli querySimple --query "SELECT * FROM CUSTOMERS" --output csv

Executes the query and displays results in CSV format.

Display as Table ​

bash
hana-cli querySimple --query "SELECT TOP 10 * FROM ORDERS"

Executes the query and displays the first 10 results as a formatted table in the terminal (default output).

Export to Excel ​

bash
hana-cli querySimple --query "SELECT * FROM PRODUCTS" --output excel --filename products.xlsx

Executes the query and exports results to an Excel file.

Export to CSV with Custom Folder ​

bash
hana-cli querySimple --query "SELECT * FROM SALES" --output csv --folder ./exports --filename sales.csv

Exports query results to a CSV file in the specified folder.

Export to JSON ​

bash
hana-cli querySimple --query "SELECT * FROM USERS" --output json --filename users.json

Exports query results to a JSON file.

Use Alias ​

bash
hana-cli qs --query "SELECT COUNT(*) as TOTAL FROM ORDERS"

Same functionality using the short alias qs.

See the Commands Reference for other commands in this category.

See Also ​