Skip to main content

A Python client for duplicating Metabase dashboard for multi schemas

Project description

Multi Schema Metabase Dashboard Helper

This Python package provides a convenient interface for interacting with the Metabase API to automate tasks such as copying and updating dashboards based on different schemas.

Requirements

  • Python 3.x
  • requests library

Installation

To use this package, you can install it via pip:

pip install multischema-metabase-dashboard-helper

Usage

--> IMPORTANT NOTE <--

You need to convert all the questions (cards) in the dashboard to sql before being able to use this to change the schema dynamically

Create dashboards Per topic

update_dashboards_for_schemas: Duplicates a template dashboard across multiple schemas, ensuring each schema has a centralized dashboard that includes all card topics. This helps in maintaining a consistent dashboard layout across different schemas, with each schema's data displayed in a similar manner. Update dashboards for different schemas

Using the GUI:

  • create a dashboard with one of the schemas you have available it will be used as the template schema.
  • include in this dashboard all the cards(questions) that you need to apply to the other schemas. (this is the from_dashboard_id that we will use in the script).

old_schema field is the name of the schema that you choose as the template schema

from metabase_api.metabase_api.api_client import MetabaseAPIClient

# Set up API credentials and parameters
api_url = "https://metabase.example.com"
username = "your_username"
password = "your_password"
database_id = 2
from_dashboard_id = 8  # Replace with the actual dashboard ID
collection_id = 130   # Replace with the actual collection ID where you want to place the copied dashboard
collection_position = 1
is_deep_copy = True
old_schema = "template_schema_name"

# Initialize the Metabase API client
api_client = MetabaseAPIClient(api_url, username, password, database_id)


api_client.update_dashboards_for_schemas(from_dashboard_id, collection_id, collection_position, is_deep_copy, old_schema)

Create dashboards Per topic

create_dashboards_for_topics: Creates new dashboards for each card topic, consolidating all cards related to that topic into one dashboard per topic. This helps in organizing and visualizing data specific to each topic within a single dashboard.

from metabase_api.metabase_api.api_client import MetabaseAPIClient

# Set up API credentials and parameters
api_url = "https://metabase.example.com"
username = "your_username"
password = "your_password"
database_id = 2
collection_id = 130   # Replace with the collection ID where you want to get the cards

# Initialize the Metabase API client
api_client = MetabaseAPIClient(api_url, username, password, database_id)

cards = api_client.get_cards_in_collection(collection_id)
if cards:
    api_client.create_dashboards_for_topics(cards)

Documentation

For detailed information about the methods and parameters provided by the MetabaseAPIClient, please refer to the source code comments and docstrings within the metabase_api package.

Note

  • Ensure that you replace placeholder values such as api_url, username, password, database_id, from_dashboard_id, collection_id, collection_position, and old_schema with your actual Metabase API credentials and parameters.
  • This package assumes familiarity with the Metabase API and its endpoints. Refer to the official Metabase API documentation for more information on available endpoints and their usage.

Disclaimer

This package is provided as-is without any warranty.

metabase-multi-schema-dashboard-duplicator

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file multischema-metabase-dashboard-helper-0.1.4.tar.gz.

File metadata

File hashes

Hashes for multischema-metabase-dashboard-helper-0.1.4.tar.gz
Algorithm Hash digest
SHA256 29fa15f65dc14fbf18ecd368e5712daf295e420c303e2a9f6c576f8fa2f4cf92
MD5 aef01560349793e5628ecdb7b9c7eb7b
BLAKE2b-256 5a42b6fef2cd82da5d59f3c5a6e8e13ab363d1784ad004c9324154c03702f851

See more details on using hashes here.

File details

Details for the file multischema_metabase_dashboard_helper-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for multischema_metabase_dashboard_helper-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 973dba4493947fe98b66ff0bcf0f0a53d4308a54deca247254d1777f9cc2c421
MD5 abf189954b579035d0f9b536b169d72a
BLAKE2b-256 1efe4871f9d22cf62032b8399fc483ffe25b98718bd3bc68d87416305806e70f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page