# How to use DBT to generate materialized views in a target database that is different from the source database?

**URL:** <https://discourse.getdbt.com/t/how-to-use-dbt-to-generate-materialized-views-in-a-target-database-that-is-different-from-the-source-database/7987>\
**Category:** Help\
**Created:** [April 24, 2023, 5:27pm UTC](https://discourse.getdbt.com/t/how-to-use-dbt-to-generate-materialized-views-in-a-target-database-that-is-different-from-the-source-database/7987 "2023-04-24T17:27:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![radouani](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/radouani/32/2298_2.png) [@radouani](https://discourse.getdbt.com/u/radouani)\
**Post date:** [April 24, 2023, 5:27pm UTC](https://discourse.getdbt.com/t/how-to-use-dbt-to-generate-materialized-views-in-a-target-database-that-is-different-from-the-source-database/7987/1 "2023-04-24T17:27:18Z")

</div>

I am newbie in dbt. I am looking to read data from providers (TRINO which is connected to cassandra) and write all intermediates views/tables in other provider like postgres/clickhouse). Trino does not allowed to rename tables (it does not have the permission to create views also as described in the official documentation).

Is there any something I am missing.

```auto
  trino:
          target: dev
          outputs:
            dev:
              type: trino
              method: none
              user: admin
              host: trino.XX.adroot
              port: 80
              schema: demo
              catalog: cassandra
        
        postgres:
          target: dev
          outputs:
            dev:
              type: postgres
              host: localhost
              user: postgres
              password: postgres
              port: 5432
              dbname: demo # or database instead of dbname
              schema: public

```

```auto
  # Name your project! Project names should contain only lowercase characters
    # and underscores. A good package name should reflect your organization's
    # name or the intended use of these models
    name: 'pmrush_elt'
    version: '1.0.0'
    config-version: 2
    
    # This setting configures which "profile" dbt uses for this project.
    profile: 'trino'
    
    # These configurations specify where dbt should look for different types of files.
    # The `model-paths` config, for example, states that models in this project can be
    # found in the "models/" directory. You probably won't need to change these!
    model-paths: ["models"]
    analysis-paths: ["analyses"]
    test-paths: ["tests"]
    seed-paths: ["seeds"]
    macro-paths: ["macros"]
    snapshot-paths: ["snapshots"]
    
    target-path: "target" # directory which will store compiled SQL files
    clean-targets: # directories to be removed by `dbt clean`
      - "target"
      - "dbt_packages"
    
    
    # Configuring models
    # Full documentation: https://docs.getdbt.com/docs/configuring-models
    
    # In this example config, we tell dbt to build all models in the example/
    # directory as views. These settings can be overridden in the individual model
    # files using the `{{ config(...) }}` macro.
    models:
      pmrush_elt:
        # Config indicated by + and applies to all files under models/example/
        staging:
          +materialized: table

```

The sources db

```auto
  version: 2
    sources:
      - name: dataforseo
        catalog: cassandra
        schema: dataforseo
        tables:
          - name: keyword_data
          - name: serp

```

The error message with Trino which explain why I want to create materialized views in antoher provider

```auto
 15:11 Found 1 model, 0 tests, 0 snapshots, 0 analyses, 316 macros, 0 operations, 0 seed files, 2 sources, 0 exposures, 0 metrics
    17:15:11  
    17:15:12 Concurrency: 1 threads (target='dev')
    17:15:12  
    17:15:12 1 of 1 START sql table model demo.stg_keyword_data ....................... [RUN]
    17:15:16 1 of 1 ERROR creating sql table model demo.stg_keyword_data .............. [ERROR in 4.87s]
    17:15:16  
    17:15:16 Finished running 1 table model in 0 hours 0 minutes and 5.11 seconds (5.11s).
    17:15:16  
    17:15:16 Completed with 1 error and 0 warnings:
    17:15:16  
    17:15:16 Database Error in model stg_keyword_data (models/staging/demo/stg_keyword_data.sql)
    17:15:16 TrinoUserError(type=USER_ERROR, name=NOT_SUPPORTED, message="This connector does not support renaming tables", query_id=20230424_171516_00019_68nw3)
    17:15:16 compiled Code at target/run/pmrush_elt/models/staging/demo/stg_keyword_data.sql
    17:15:16  
    17:15:16 Done. PASS=0 WARN=0 ERROR=1 SKIP=0 TOTAL=1

```
