Skip to content

Instantly share code, notes, and snippets.

@alathaVBO
alathaVBO / mysql-docker.sh
Created February 28, 2023 13:11 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@alathaVBO
alathaVBO / superset_sankey_role_table_dashboard.sql
Created January 23, 2023 10:08 — forked from pajachiet/superset_sankey_role_table_dashboard.sql
This allows to create the base table for a dashboard with a sankey diagram visualizing relationships between role, table and dashboards
CREATE OR REPLACE VIEW table_to_role AS (
SELECT
tables.id as table_id,
tables.table_name as table_name,
ab_role.name as role_name
FROM
tables
LEFT JOIN ab_view_menu ON ab_view_menu.name = tables.perm
LEFT JOIN ab_permission_view on ab_permission_view.view_menu_id = ab_view_menu.id
LEFT JOIN ab_permission on ab_permission_view.permission_id = ab_permission.id
@alathaVBO
alathaVBO / create_superset_users.py
Created January 23, 2023 10:04 — forked from pajachiet/create_superset_users.py
Scripting on Superset backend to fix bugs or automate tasks
#!/usr/bin/env python
# coding: utf8
# Script to create superset users
import pandas as pd
from sqlalchemy import create_engine
import datetime
import pexpect
import os
@alathaVBO
alathaVBO / example.md
Created June 10, 2022 08:24 — forked from devdrops/example.md
Mysqldump from Docker container

Mysqldump from Docker container

docker exec -i mysql_container mysqldump -uroot -proot --databases database_name --skip-comments > /path/to/my/dump.sql

OBS

  • This will generate a dump.sql file in your host machine. Awesome, eh?
  • Avoid using --compact on your dump. This will make MySQL check your constraints which will cause troubles when reading your file (damm you MySQL). And don't use --force to fix this scenario: recreate your dump without --compact ¯_(ツ)_/¯