mirror of
https://github.com/apache/superset.git
synced 2026-04-25 11:04:48 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user