After installing the ibm-lh-client
package, you can use the utilities to
run SQL queries in watsonx.data.
watsonx.data Developer
edition
watsonx.data on IBM Software
Hub
watsonx.data on IBM Cloud®
About this task
Complete the following steps to run an SQL query through the CLI.
Procedure
- Establish connection with
Presto
engine by using the
ibm-lh-client
package. For more information about installation, see Establishing connection to watsonx.data using ibm-lh-client package utilities.
- Use
presto-cli
utility to run SQL queries directly or from inside the
Presto
CLI. bin/presto-cli --engine=<ENGINE_NAME> --catalog=<Catalog_name> <<< "SQL_query"
or
bin/presto-cli --engine=<ENGINE_NAME>
Parameter value:
- <ENGINE_NAME>: Enter the engine name that you added.
- <Catalog_name>: Specify the catalog name within where you want to query. (Optional)
- Use
presto-run
utility to run SQL
queries. bin/presto-run --engine=<ENGINE_NAME> --catalog=<Catalog_name> <<< "SQL_query"
or
bin/presto-run --engine=<ENGINE_NAME>
Parameter value:
- <ENGINE_NAME>: Enter the engine name that you added.
- <Catalog_name>: Specify the catalog name within where you want to query. (Optional)
SQL queries using Sandbox directory
- Set the
LH_SANDBOX_DIR
mount by referring Creating a sandbox directory.
- Use the following command to run an SQL file from your
LH_SANDBOX_DIR
mount. bin/presto-cli --engine=<ENGINE_NAME> --file=<PATH_SANDBOX_DIR_SQL_FILE>
or
bin/presto-run --engine=<ENGINE_NAME> --file=<PATH_SANDBOX_DIR_SQL_FILE>
Parameter value:
- <ENGINE_NAME>: Enter the engine name that you added.
<PATH_SANDBOX_DIR_SQL_FILE>
: Specify the SQL query file location available
in your sandbox directory. For example: /home/jmouse/mysandbox/sample.sql.