feat: export databases as a ZIP bundle (#11229)

* Export databases as Zip file

* Fix tests

* Address comments

* Implement mulexport for database

* Fix lint

* Fix lint
This commit is contained in:
Beto Dealmeida
2020-10-16 11:10:39 -07:00
committed by GitHub
parent 8863c939ad
commit 94e23bfc82
16 changed files with 559 additions and 35 deletions

View File

@@ -15,6 +15,8 @@
# specific language governing permissions and limitations
# under the License.
import logging
import re
import unicodedata
from typing import Any, Dict, List, Optional
from sqlalchemy.orm import Session
@@ -22,6 +24,7 @@ from sqlalchemy.orm import Session
from superset.connectors.druid.models import DruidCluster
from superset.models.core import Database
IMPORT_EXPORT_VERSION = "1.0.0"
DATABASES_KEY = "databases"
DRUID_CLUSTERS_KEY = "druid_clusters"
logger = logging.getLogger(__name__)
@@ -95,3 +98,18 @@ def import_from_dict(
session.commit()
else:
logger.info("Supplied object is not a dictionary.")
def strip_accents(text: str) -> str:
text = unicodedata.normalize("NFD", text).encode("ascii", "ignore").decode("utf-8")
return str(text)
def sanitize(name: str) -> str:
"""Sanitize a post title into a directory name."""
name = name.lower().replace(" ", "_")
name = re.sub(r"[^\w]", "", name)
name = strip_accents(name)
return name