记录一下Superset二开相关接口信息,方便后面查询
/superset/explore/?form_data=%7B%22slice_id%22%3A1%7D&slice_id=1&action=overwrite&slice_name=demo&save_to_dashboard_id=1
根目录\superset\views\core.py
- @has_access
- @event_logger.log_this
- @expose("/explore/
//" , methods=["GET", "POST"]) - @expose("/explore/", methods=["GET", "POST"])
- @expose("/explore/p/
/" , methods=["GET"]) - # pylint: disable=too-many-locals,too-many-branches,too-many-statements
- def explore(
- self,
- datasource_type: Optional[str] = None,
- datasource_id: Optional[int] = None,
- key: Optional[str] = None,
- ) -> FlaskResponse:
- initial_form_data = {}
-
- form_data_key = request.args.get("form_data_key")
-
- if action == "saveas" and slice_add_perm:
- ChartDAO.save(slc)
- msg = _("Chart [{}] has been saved").format(slc.slice_name)
- flash(msg, "success")
- elif action == "overwrite" and slice_overwrite_perm:
- ChartDAO.overwrite(slc)
- msg = _("Chart [{}] has been overwritten").format(slc.slice_name)
- flash(msg, "success")
/api/v1/dataset/
- {database: 1, schema: "datacollect", table_name: "cgmx_out"}
- database: 1
- schema: "datacollect"
- table_name: "cgmx_out"}
根目录\superset\views\core.py
\superset\dao\base.py
- @classmethod
- def create(cls, properties: Dict[str, Any], commit: bool = True) -> Model:
- """
- Generic for creating models
- :raises: DAOCreateFailedError
- """
- if cls.model_cls is None:
- raise DAOConfigError()
- model = cls.model_cls() # pylint: disable=not-callable
- for key, value in properties.items():
- setattr(model, key, value)
- try:
- db.session.add(model)
- if commit:
- db.session.commit()
- except SQLAlchemyError as ex: # pragma: no cover
- db.session.rollback()
- raise DAOCreateFailedError(exception=ex) from ex
- return model
- @classmethod
- def save(cls, instance_model: Model, commit: bool = True) -> Model:
- """
- Generic for saving models
- :raises: DAOCreateFailedError
- """
- if cls.model_cls is None:
- raise DAOConfigError()
- if not isinstance(instance_model, cls.model_cls):
- raise DAOCreateFailedError(
- "the instance model is not a type of the model class"
- )
- try:
- db.session.add(instance_model)
- if commit:
- db.session.commit()
- except SQLAlchemyError as ex: # pragma: no cover
- db.session.rollback()
- raise DAOCreateFailedError(exception=ex) from ex
- return instance_model
- @classmethod
- def update(
- cls, model: Model, properties: Dict[str, Any], commit: bool = True
- ) -> Model:
- """
- Generic update a model
- :raises: DAOCreateFailedError
- """
- for key, value in properties.items():
- setattr(model, key, value)
- try:
- db.session.merge(model)
- if commit:
- db.session.commit()
- except SQLAlchemyError as ex: # pragma: no cover
- db.session.rollback()
- raise DAOUpdateFailedError(exception=ex) from ex
- return model
- @classmethod
- def delete(cls, model: Model, commit: bool = True) -> Model:
- """
- Generic delete a model
- :raises: DAODeleteFailedError
- """
- try:
- db.session.delete(model)
- if commit:
- db.session.commit()
- except SQLAlchemyError as ex: # pragma: no cover
- db.session.rollback()
- raise DAODeleteFailedError(exception=ex) from ex
- return model