Snowflake
Connecting DinMo to Snowflake: Step-by-Step Guide
CREATE warehouse IF NOT EXISTS identifier('DINMO_WAREHOUSE')
warehouse_size = xsmall
warehouse_type = standard
auto_suspend = 60
auto_resume = TRUE
initially_suspended = TRUE;-- Edit the variables between < > with your snowflake connection information
SET INPUT_ROLE='ACCOUNTADMIN'; -- or any other role with the needed permissions
SET dinmo_service_user='DINMO_SERVICE_USER'; -- a specific role with the minimal permissions is created for DinMo to operate
SET dinmo_access_role_name='DINMO_ACCESS_ROLE'; -- you can modify this name
-- If you previously created a warehouse in step 1, you can replace 'COMPUTE_WH' with its name
SET COMPUTE_WAREHOUSE='COMPUTE_WH';
-- Specify the database where your data to be synced is stored, the database where DinMo will store technical data,, and define a default schema
SET DATA_MODEL='<database>'; -- the database in which your data is stored
SET default_namespace='<database.schema>'; -- this schema should be located in the database mentioned above
SET DINMO_INTERNAL_DATABASE='DINMO_DB'; -- this database will be created by the script. There, DinMo will store technical data. You can modify this name.
-- Set role for grants
USE ROLE identifier($INPUT_ROLE);
-- Create a role for DinMo
CREATE ROLE IF NOT EXISTS identifier($dinmo_access_role_name);
-- Grant permissions to the role
GRANT USAGE ON WAREHOUSE identifier($COMPUTE_WAREHOUSE) TO ROLE identifier($dinmo_access_role_name);
GRANT USAGE ON DATABASE identifier($DATA_MODEL) TO ROLE identifier($dinmo_access_role_name);
GRANT USAGE ON ALL SCHEMAS IN DATABASE identifier($DATA_MODEL) TO ROLE identifier($dinmo_access_role_name);
GRANT SELECT ON ALL TABLES IN DATABASE identifier($DATA_MODEL) TO ROLE identifier($dinmo_access_role_name);
GRANT SELECT ON ALL VIEWS IN DATABASE identifier($DATA_MODEL) TO ROLE identifier($dinmo_access_role_name);
GRANT USAGE ON FUTURE SCHEMAS IN DATABASE identifier($DATA_MODEL) TO ROLE identifier($dinmo_access_role_name);
GRANT SELECT ON FUTURE TABLES IN DATABASE identifier($DATA_MODEL) TO ROLE identifier($dinmo_access_role_name);
GRANT SELECT ON FUTURE VIEWS IN DATABASE identifier($DATA_MODEL) TO ROLE identifier($dinmo_access_role_name);
-- Create the database with the schemas DinMo will use
CREATE DATABASE IF NOT EXISTS identifier($DINMO_INTERNAL_DATABASE);
USE DATABASE identifier($DINMO_INTERNAL_DATABASE);
CREATE SCHEMA IF NOT EXISTS DINMO_DELTA_STORAGE;
CREATE SCHEMA IF NOT EXISTS DINMO_SEGMENTS;
CREATE SCHEMA IF NOT EXISTS DINMO_STATS;
CREATE SCHEMA IF NOT EXISTS DINMO_PREDICTIONS;
-- Grant full permissions only to these DinMo schemas
GRANT ALL PRIVILEGES ON DATABASE identifier($DINMO_INTERNAL_DATABASE) TO ROLE identifier($dinmo_access_role_name);
GRANT ALL ON SCHEMA DINMO_DELTA_STORAGE TO ROLE identifier($dinmo_access_role_name);
GRANT ALL ON SCHEMA DINMO_SEGMENTS TO ROLE identifier($dinmo_access_role_name);
GRANT ALL ON SCHEMA DINMO_STATS TO ROLE identifier($dinmo_access_role_name);
GRANT ALL ON SCHEMA DINMO_PREDICTIONS TO ROLE identifier($dinmo_access_role_name);
-- Create DinMo's user
-- SET user_password='<strong password>'; -- Uncomment this line if you have chosen the Password authentification method.
CREATE USER IF NOT EXISTS identifier($dinmo_service_user)
-- PASSWORD=$user_password -- Uncomment this line if you have chosen the Password authentification method.
DEFAULT_ROLE=$dinmo_access_role_name
DEFAULT_WAREHOUSE=$COMPUTE_WAREHOUSE
DEFAULT_NAMESPACE=$default_namespace;
-- Assign the role to the user
GRANT ROLE identifier($dinmo_access_role_name) TO USER identifier($dinmo_service_user);

Last updated
