Skip to main content

CLI tool to import and export Metabase items (questions, dashboards, collections) across instances

Project description

Metashovel

Metashovel is a Metabase utility tool to mainly import/export questions and dashboards

Setup

Running from source

  1. Install Pipenv command in your system: sudo apt install pipenv
  2. Install dependencies from the root of this project directory: pipenv install
  3. Open shell with requirements loaded in a virtual environment: pipenv shell

Configuration

Depending on subcommand, you configure the cli with:

  1. environment variables (mostly for credentials eg API keys, or access urls, eg. url to database with user, pass, hostname, db name)
  2. command line switches and arguments

Environment variables reference

  1. API keys and Database access urls

Metashovel uses the Metabase API. Define Metabase url, username and password with these variables:

  • METABASE_ENDPOINT - url of Metabase instance with scheme, eg: https://data.awesome.com
  • METABASE_AUTH_EMAIL - email for login
  • METABASE_AUTH_PASSWORD - password for login

Usage

Metashovel has a set of subcommands, similar to git or heroku.

Export

metashovel export generates a JSON dump of all the data required to import the collections / dashboards / questions given in options.

The generated JSON is printed on standard output. It contains a property items with the list of objects that got exported, as well as a property mappings with information to translate ids that make sense only in the context of a Metabase instance (table ids, card ids, etc).

Options:

  • -c "Some collection" - Exports all the questions and dashboards contained in the named collection and its child collections. You should ensure that the dashboards refer only to questions contained within that collection, unless you plan to import the data within the same Metabase instance. The collection must exist.

Import

metashovel import reads a JSON dump generated by the export command and import the object into a Metabase instance.

Options:

  • -c "Some collection" - The name of the collection into which the objects should be imported. The collection must exist and be empty (no support for overwrite / merge at the moment).
  • -j /path/to/file.json - The JSON file to import.

Package building

To build the package use python setup.py bdist_wheel.

To install the package locally:

pip install --upgrade dist/metashovel-0.1-py3-none-any.whl

To upload it to PyPI:

  1. Create a ~/.pypirc file:
[distutils] 
index-servers=pypi
[pypi] 
repository = https://upload.pypi.org/legacy/ 
username = pypi-username
  1. Use python -m twine upload dist/*.

Contributing

TODO

Code Linting and Formatting

A pylint configuration is in pylintrc - configure your editor to run it automatically. Use black for formatting.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

metashovel-0.3.3-py3-none-any.whl (18.5 kB view hashes)

Uploaded Python 3

Supported by

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