# Cannot connect to Snowflake Database from Cloud dbt IDE

**URL:** <https://discourse.getdbt.com/t/cannot-connect-to-snowflake-database-from-cloud-dbt-ide/14678>\
**Category:** Help\
**Tags:** snowflake, dbt-cloud\
**Created:** [August 5, 2024, 6:46pm UTC](https://discourse.getdbt.com/t/cannot-connect-to-snowflake-database-from-cloud-dbt-ide/14678 "2024-08-05T18:46:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![krecithus](https://avatars.discourse-cdn.com/v4/letter/k/e5b9ba/32.png) [@krecithus](https://discourse.getdbt.com/u/krecithus)\
**Post date:** [August 5, 2024, 6:46pm UTC](https://discourse.getdbt.com/t/cannot-connect-to-snowflake-database-from-cloud-dbt-ide/14678/1 "2024-08-05T18:46:55Z")

</div>

## Issue

I have trouble replicating Step 7 of ’ Quickstart for dbt Cloud and Snowflake’. I tried to create the customers model but my dbt run failed. Error is ‘Database ‘RAW’ does not exist or not authorized’.’

## Update 8/5/2024

After I granted permissions specifically to ‘PC\_dbt\_ROLE’ in snowflake ‘RAW’ database, the error message has changed to 'Object ‘RAW.JAFFLE\_SHOP.CUSTOMERS’ does not exist or not authorized. I assume that means I now have access to RAW db and JAFFLE\_SHOP schema but no access to the customers table.

## Other Details

The role in my project setting is PC\_dbt\_ROLE, and ‘session keep live’ is unchecked. Not sure what I have missed.

## Some example code or error messages

```auto
18:42:02 Began running node model.my_new_project.customers
18:42:02 1 of 3 START sql view model dbt_XXie.customers ................................. [RUN]
18:42:02 Began compiling node model.my_new_project.customers
18:42:02 Writing injected SQL for node "model.my_new_project.customers"
18:42:02 Began executing node model.my_new_project.customers
18:42:02 Writing runtime sql for node "model.my_new_project.customers"
18:42:02 Using snowflake connection "model.my_new_project.customers"
18:42:02 On model.my_new_project.customers: /* {"app": "dbt", "dbt_version": "2024.8.221", "profile_name": "user", "target_name": "default", "node_id": "model.my_new_project.customers"} */
create or replace view PC_DBT_DB.dbt_XXie.customers
  
   as (
    with customers as (

    select
        id as customer_id,
        first_name,
        last_name

    from raw.jaffle_shop.customers

),

orders as (

    select
        id as order_id,
        user_id as customer_id,
        order_date,
        status

    from raw.jaffle_shop.orders

),

customer_orders as (

    select
        customer_id,

        min(order_date) as first_order_date,
        max(order_date) as most_recent_order_date,
        count(order_id) as number_of_orders

    from orders

    group by 1

),

final as (

    select
        customers.customer_id,
        customers.first_name,
        customers.last_name,
        customer_orders.first_order_date,
        customer_orders.most_recent_order_date,
        coalesce(customer_orders.number_of_orders, 0) as number_of_orders

    from customers

    left join customer_orders using (customer_id)

)

select * from final
  );
18:42:02 Opening a new connection, currently in state closed
18:42:02 Snowflake adapter: Snowflake query id: 01b626e2-0306-d23a-0000-0007caebc23d
18:42:02 Snowflake adapter: Snowflake error: 002003 (02000): 01b626e2-0306-d23a-0000-0007caebc23d: SQL compilation error:
Database 'RAW' does not exist or not authorized.
18:42:02 On model.my_new_project.customers: Close
18:42:02 Database Error in model customers (models/customers.sql)
  002003 (02000): 01b626e2-0306-d23a-0000-0007caebc23d: SQL compilation error:
  Database 'RAW' does not exist or not authorized.
  compiled Code at target/run/my_new_project/models/customers.sql
18:42:02 1 of 3 ERROR creating sql view model dbt_XXie.customers ........................ [e[31mERRORe[0m in 0.30s]
18:42:02 Finished running node model.my_new_project.customers
18:42:04 Database Error in model customers (models/customers.sql)
  002003 (02000): 01b626e2-0306-d23a-0000-0007caebc23d: SQL compilation error:
  Database 'RAW' does not exist or not authorized.
  compiled Code at target/run/my_new_project/models/customers.sql

```

---

<div class="post-metadata">

**Author:** ![krecithus](https://avatars.discourse-cdn.com/v4/letter/k/e5b9ba/32.png) [@krecithus](https://discourse.getdbt.com/u/krecithus)\
**Post date:** [August 7, 2024, 9:13pm UTC](https://discourse.getdbt.com/t/cannot-connect-to-snowflake-database-from-cloud-dbt-ide/14678/2 "2024-08-07T21:13:19Z")

</div>

I solved this issue by granting USAGE permission to all databases and schemas that my model uses and SELECT permission to my tables.

---

<div class="post-metadata">

**Author:** ![sravyats94](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@sravyats94](https://discourse.getdbt.com/u/sravyats94)\
**Post date:** [September 12, 2024, 9:14pm UTC](https://discourse.getdbt.com/t/cannot-connect-to-snowflake-database-from-cloud-dbt-ide/14678/3 "2024-09-12T21:14:41Z")

</div>

tried this but didn’t worked

---

<div class="post-metadata">

**Author:** ![omolori](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/omolori/32/4739_2.png) [@omolori](https://discourse.getdbt.com/u/omolori)\
**Post date:** [October 15, 2024, 5:30am UTC](https://discourse.getdbt.com/t/cannot-connect-to-snowflake-database-from-cloud-dbt-ide/14678/4 "2024-10-15T05:30:32Z")

</div>

how did you do that, the specific code or setting
