Superset plugin to swap all chart datasources in a dashboard to a target database
Project description
superset-promote-dashboard
A Superset plugin that lets you swap all chart datasources in a dashboard from one database connection to another in one click — useful for promoting dashboards between environments (dev → staging → prod).
How it works
- Pick a dashboard and a target database connection
- Preview — see which charts will be swapped, which have no match, and which are already on the target
- Promote — each chart is updated to the matching dataset in the target DB, matched by table name
Charts are matched by table_name (and schema when set). Virtual datasets (SQL-based) are skipped.
Installation
pip install superset-promote-dashboard
Register the plugin in your superset_config.py:
def init_promote_plugin(app):
try:
from superset_promote_dashboard.promote_view import PromoteDashboardView
import os, superset_promote_dashboard
from jinja2 import ChoiceLoader, FileSystemLoader
app.appbuilder.add_view(
PromoteDashboardView,
"Promote Dashboard",
icon="fa-arrow-circle-up",
category="Custom Tools",
category_icon="fa-wrench",
)
sm = app.appbuilder.sm
admin_role = sm.find_role("Admin")
if admin_role:
grants = [
("menu_access", "Promote Dashboard"),
("menu_access", "Custom Tools"),
("can_index", "PromoteDashboardView"),
("can_api_preview", "PromoteDashboardView"),
("can_api_promote", "PromoteDashboardView"),
]
for action, view_name in grants:
pvm = sm.add_permission_view_menu(action, view_name)
if pvm:
sm.add_permission_role(admin_role, pvm)
pkg_templates = os.path.join(os.path.dirname(superset_promote_dashboard.__file__), "templates")
if os.path.exists(pkg_templates):
from jinja2 import ChoiceLoader, FileSystemLoader
app.jinja_env.loader = ChoiceLoader([app.jinja_env.loader, FileSystemLoader(pkg_templates)])
except Exception as e:
import logging
logging.getLogger(__name__).error(f"Failed to register promote-dashboard plugin: {e}")
FLASK_APP_MUTATOR = init_promote_plugin
Restart Superset — Custom Tools → Promote Dashboard will appear in the navigation.
Local development
Requires Docker.
docker compose up
This starts:
- postgres — one container serving three databases:
superset,db_source,db_target - superset — Apache Superset 4.1.1 with the plugin installed, at http://localhost:8088
- superset-init — one-shot container that runs migrations, creates the admin user, seeds database connections, datasets, and the "Academic Overview" demo dashboard
Login: admin / admin
Demo data
The test environment uses a high-school theme to make the source vs. target difference obvious:
| Database | Contents |
|---|---|
| Source DB | 2023-2024 school year — 20 students, 50 grade records (Q1-Q4), 36 attendance records |
| Target DB | 2024-2025 cohort — 6 students, 15 grade records (Q1-Q3 in progress), 10 attendance records |
Tables in both databases: students, grades, attendance.
Promoting the demo dashboard
- Navigate to Custom Tools → Promote Dashboard
- Select Academic Overview and Target DB
- Click Preview — all 5 charts should show "Will swap"
- Click Promote — charts are updated; reload the dashboard to see the new cohort's data
- Run Preview again — all charts now show "Already on target"
Security
- All routes are protected by
@has_access— unauthenticated requests redirect to login - CSRF is fully enabled; the plugin generates a CSRF token via
generate_csrf()and forwards it in both the browser meta tag and all server-sidePUTcalls to the Superset API - Admin role permissions are granted automatically on startup; other roles can be granted access through Security → List Roles in the Superset UI
Requirements
- Apache Superset 4.x
- Python 3.10+
flask-wtf(included with Superset)
Project details
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file superset_promote_dashboard-0.1.0.tar.gz.
File metadata
- Download URL: superset_promote_dashboard-0.1.0.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.4.1 CPython/3.10.20 Linux/6.17.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
debcc6f65ccd810c7e03f79dca5179ad58eff9dc9bae6f5c4693b3788325c846
|
|
| MD5 |
c55d6691fe0af14788d02f440d4f5406
|
|
| BLAKE2b-256 |
7ce2550eaf1e4856a73657c2e78d9369b0b60acee366947f58b5cc56d7665ae4
|
File details
Details for the file superset_promote_dashboard-0.1.0-py3-none-any.whl.
File metadata
- Download URL: superset_promote_dashboard-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.4.1 CPython/3.10.20 Linux/6.17.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
034a07837b6612bd234871d81bacefb0c255efb32cf23d2c980162590c260d7a
|
|
| MD5 |
2309b2046fdf088a604adae24d85cb09
|
|
| BLAKE2b-256 |
82e5b9bd544705caf8a9dd9f47018e21a7a10f1becff20ce5f0a08f46a50d0b0
|