{"id":13343202,"url":"https://github.com/anki-code/metabase-sql-wrapper","last_synced_at":"2025-03-21T08:31:21.322Z","repository":{"id":103638962,"uuid":"299666045","full_name":"anki-code/metabase-sql-wrapper","owner":"anki-code","description":"This is a docker-container based on Metabase container that automatically saves Metabase H2 database to SQL-file and creates Metabase H2 database from SQL-file.","archived":false,"fork":false,"pushed_at":"2025-03-04T13:09:52.000Z","size":37,"stargazers_count":50,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-17T23:02:34.246Z","etag":null,"topics":["docker","metabase","sql","xonsh"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anki-code.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-09-29T15:54:35.000Z","updated_at":"2025-03-04T13:09:57.000Z","dependencies_parsed_at":"2024-10-28T10:14:00.637Z","dependency_job_id":"ae0e614c-2137-4775-918a-ebec33c52c20","html_url":"https://github.com/anki-code/metabase-sql-wrapper","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anki-code%2Fmetabase-sql-wrapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anki-code%2Fmetabase-sql-wrapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anki-code%2Fmetabase-sql-wrapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anki-code%2Fmetabase-sql-wrapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anki-code","download_url":"https://codeload.github.com/anki-code/metabase-sql-wrapper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244765008,"owners_count":20506747,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","metabase","sql","xonsh"],"created_at":"2024-07-29T19:30:42.560Z","updated_at":"2025-03-21T08:31:21.302Z","avatar_url":"https://github.com/anki-code.png","language":"Python","readme":"\u003cp align=\"center\"\u003e\nmetabase-sql-wrapper is a Docker container based on the Metabase container. It automatically saves the Metabase H2 database to an SQL file when the container stops and recreates the H2 database from the SQL file when the container starts (if the database does not already exist).\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\nThis allows to save the Metabase H2 database SQL-file to Git, versioning changes\u003cbr\u003e and restore the database from SQL-file.\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\nIf you like the idea click ⭐ on the repo and stay tuned.\n\u003c/p\u003e\n\n## Run container\n```shell script\ngit clone https://github.com/anki-code/metabase-sql-wrapper\ncd metabase-sql-wrapper\ndocker-compose up\n```\n\n## How it works\n\n1. [`docker-compose.yml`](https://github.com/anki-code/metabase-sql-wrapper/blob/master/docker-compose.yml) file has environment variables:\n\n    ```shell script\n    MB_DB_FILE: /data/metabase\n    MB_DB_INIT_SQL_FILE: /data/metabase.db.sql     # (optional) used to build the DB if MB_DB_FILE doesn't exists \n    MB_DB_SAVE_TO_SQL_FILE: /data/metabase.db.sql  # (optional) used to save SQL when container was stopped\n    ```\n\n2. `docker-compose up` runs `run.xsh` with [xonsh shell](https://xon.sh/) wrapper that catches \nthe docker signals and environment variables and do saving or creating the Metabase DB after stopping \nor before starting the container.\n\n3. If `MB_DB_INIT_SQL_FILE` is set and `MB_DB_FILE` directory doesn't exists then before running Metabse \nthe database will be created from the SQL-file.\n\n4. If `MB_DB_SAVE_TO_SQL_FILE` is set and the container will get stop/restart signal then the database will be saved \nto SQL-file after Metabase has been stopped.\n\nThis way you can run container, save your queries to Metabase, stop the container and commit it to Git.\n\n## Cleaning the database before commit to Git\n\nBy default Metabase writes logs and history to the database. To clean this before commit to Git you can \nuse the [`metabase-db-clean.sql`](https://github.com/anki-code/metabase-sql-wrapper/blob/473f3fd23829216cc4384df3bbbda5a3dcd7eec6/metabase-db-clean.sql) script:\n```bash\njava -cp metabase.jar org.h2.tools.RunScript -url jdbc:h2:./metabase.db -script /path/to/repository/metabase-db-clean.sql\n```\n\n## Links\n\n* This container based on [docker-xonsh-wrapper](https://github.com/anki-code/docker-xonsh-wrapper)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanki-code%2Fmetabase-sql-wrapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanki-code%2Fmetabase-sql-wrapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanki-code%2Fmetabase-sql-wrapper/lists"}