Granting Data Access
The Genesis Bots can help you analyze your data in Snowflake. To do so, you need to grant this application access to your data. The helper procedure below can help you grant access to read all tables and views in a database to this application.
Note: Any Genbot with the Database Tools will be able to access this data, and when such a Genbot is deployed to Slack, any user of Slack will be able to run analyses of this data using the Genbot. So grant data in this manner only to non-sensitive data that is ok for any Slack user to view.
In order to take full advantage of the Genesis Genbots, you must allow them access to specific objects in your Snowflake account. Click on the “Grant Data Access” page in the Streamlit side menu to open up a set of helper scripts.
The scripts will create a stored procedure that accepts a database name and Genesis Bots application name as arguments and will grant SELECT access to all tables and views in all schemas of that database.
The procedure will be created in the GENESIS_LOCAL_DB.SETTINGS schema, which was created as a part of the installation and configuration process.
Copy the code below & run it in a Snowflake Snowsight worksheet.
In the worksheet, ensure that the APP_DATABASE parameter is set to the correct Genesis Bots application name. Set the role, context, and warehouse before creating the stored procedure. The procedure accepts the application name (APP_NAME) and database name (database_name) as parameters. It will find all of the schemas that exist in the database, excluding the INFORMATION_SCHEMA schema, and loop through each, granting the following privileges to the Genesis Bots application:
-
USAGE on the database
-
USAGE on each schema
-
SELECT on all tables in each schema
-
SELECT on all views in each schema
Note: Granting privileges to the Genesis Bots application does not provide the Genesis provider access to your data or metadata. Only the Genesis Bots application will be able to take advantage of the privileges granted.
The stored procedure is meant to help grant the Genesis Bots application access to appropriate data in your Snowflake account. However, it can be modified, as necessary, to include or exclude specific schemas, objects, etc.
Next, run the “show databases” command to view the available databases in your account.
Call the “grant_schema_usage_and_select_to_app()” procedure, passing in the database name that you’d like to grant privileges on and the application name.
To verify that the database and its objects were granted successfully, browse to the “Harvester Status” page in the Genesis Bots Streamlit application. Here you can see all databases and schemas that have been granted to the application.
The harvest status shows how many Snowflake objects have been crawled by the Genesis Harvest Service, meaning their metadata was gathered and stored to inform the Genbots which objects are available for query, and which schemas are either included or excluded from the metadata harvesting service.
As you can see below, the recently added WEATHER_DB has 1 schema, PUBLIC, which contains 3 harvestable objects.