<@U06GU1FBM24> Hi, does elementary work with two d...
# ask-elementary-ai
n
@Andres Crucetta Hi, does elementary work with two databases? We have our DBT plugged in to two different databases. e.g.,
+database: "{{ 'citus' if target.name in ['dev', 'qa', 'prod'] else 'etl_data' }}"
k
A message from kapa.ai
New message text here
a
@kapa.ai Assuming I have tests I want to run for tables in each database (e.g., citus and specialty are their names). How can I run all the tests in both DBs but dump the results in one.
k
A message from kapa.ai
Elementary does not natively support running tests across multiple databases and consolidating all results into a single database or schema. If you configure multiple dbt projects or targets to write to the same Elementary schema (in the same database), the metadata and results tables will be overwritten or truncated by each run, leading to loss of data from previous runs. This is because some Elementary models (especially metadata tables) use a "truncate and insert" pattern, not incremental loading, so only the latest project's data will be present [Trusted Support Staff explanation](https://slack.com/archives/C02CTC89LAX/p1673857363237629) [Official statement on multi-project support](https://slack.com/archives/C02CTC89LAX/p1692783440340999). The only community-supported workaround is to run Elementary separately for each database (or dbt project), each writing to its own schema or database, and then manually union the results into a central location for reporting. Some users have done this by creating views or tables that union the Elementary tables from each schema/database, and then pointing the Elementary CLI at this consolidated location to generate reports. However, this approach is not officially supported and requires manual setup [Community workaround](https://slack.com/archives/C02CTC89LAX/p1686010688754099) [Trusted Support Staff suggestion](https://slack.com/archives/C02CTC89LAX/p1678311437497399). Summary: - You cannot natively run tests in multiple databases and have Elementary automatically consolidate all results into one database. - The recommended approach is to have a separate Elementary schema for each database, then manually union the results if you need a consolidated view. - There is no built-in filter or configuration to direct all test results from multiple databases into a single Elementary schema without risk of data loss or overwriting. If this is a critical need, you may want to follow or contribute to the open feature requests for multi-project or multi-database support in Elementary [Feature request](https://github.com/elementary-data/elementary/issues/1324).
a
@kapa.ai Assuming we have the tests results in two different databases, can I build two different HTML reports for each database? Or how would that work?
k
A message from kapa.ai
Yes, you can build two different HTML reports for each database. The recommended approach is to configure each dbt project (or target) to write Elementary's results to a separate schema (or database). Then, you can run the Elementary CLI (e.g.,
edr report
) separately for each schema/database to generate individual reports. This is the suggested workaround since using the same schema/database for multiple dbt projects or databases can cause data to be overwritten. By keeping the results separate, you ensure each report accurately reflects the tests and metadata for its respective database [Trusted Support Staff explanation](https://slack.com/archives/C02CTC89LAX/p1674241350877809) [Recommendation for separate datasets](https://slack.com/archives/C02CTC89LAX/p1674632249905459). In summary: - Configure each environment to write to its own Elementary schema/database. - Run
edr report
for each schema/database to generate separate HTML reports. This is currently the best practice for handling multiple databases with Elementary.