You can access the databases and tables within the Base module using snowSQL command-line interface. This is useful for external collaborators who do not have access to ICA core functionalities. In this tutorial we will describe how to obtain the token and use it for accessing the Base module. This tutorial does not cover how to install and configure snowSQL.
Once the Base module has been enabled within a project, the following details are shown in Projects > your_project > Project Settings > Details.
After clicking the button Create OAuth access token
, the pop-up authenticator is displayed.
After clicking the button Generate snowSQL command
the pop-up authenticator presents the snowSQL command.
Copy the snowSQL command and run it in the console to log in.
You can also get the OAuth access token via API by providing <PROJECT ID> and <YOUR KEY>.
API Call:
Response
Template snowSQL:
Now you can perform a variety of tasks such as:
Querying Data: execute SQL queries against tables, views, and other database objects to retrieve data from the Snowflake data warehouse.
Creating and Managing Database Objects: create tables, views, stored procedures, functions, and other database objects in Snowflake. you can also modify and delete these objects as needed.
Loading Data: load data into Snowflake from various sources such as local files, AWS S3, Azure Blob Storage, or Google Cloud Storage.
Overall, snowSQL CLI provides a powerful and flexible interface to work with Snowflake, allowing external users to manage data warehouse and perform a variety of tasks efficiently and effectively without access to the ICA core.
Show all tables in the database:
Create a new table:
List records in a table:
Load data from a file: To load data from a file, you can start by create a staging area in the internal storage using the following commend:
You can then upload the local file to the internal storage using the following command:
You can check if the file was uploaded properly using LIST command:
Finally, Load data by using COPY TO command. The command assumes the data.tsv is a tab delimited file. You can easily modify the following command to import JSON file setting TYPE=JSON.
Load data from a string: If you have data as JSON string, you can import the data into the tables using following commands.
Load data into specific columns: If you want to load sample_name into the table, you can remove the "count" from the column and the value list as below:
List the views of the database to which you are connected. As shared database and catalogue views are created within the project database, they will be listed. However, it does not show views which are granted via another database, role or from bundles.
Show grants, both directly on the tables and views and grants to roles which in turn have grants on tables and views.