本文整理汇总了Python中superset.connectors.connector_registry.ConnectorRegistry.get_eager_datasource方法的典型用法代码示例。如果您正苦于以下问题:Python ConnectorRegistry.get_eager_datasource方法的具体用法?Python ConnectorRegistry.get_eager_datasource怎么用?Python ConnectorRegistry.get_eager_datasource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类superset.connectors.connector_registry.ConnectorRegistry
的用法示例。
在下文中一共展示了ConnectorRegistry.get_eager_datasource方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: export_dashboards
# 需要导入模块: from superset.connectors.connector_registry import ConnectorRegistry [as 别名]
# 或者: from superset.connectors.connector_registry.ConnectorRegistry import get_eager_datasource [as 别名]
def export_dashboards(cls, dashboard_ids):
copied_dashboards = []
datasource_ids = set()
for dashboard_id in dashboard_ids:
# make sure that dashboard_id is an integer
dashboard_id = int(dashboard_id)
copied_dashboard = (
db.session.query(Dashboard)
.options(subqueryload(Dashboard.slices))
.filter_by(id=dashboard_id).first()
)
make_transient(copied_dashboard)
for slc in copied_dashboard.slices:
datasource_ids.add((slc.datasource_id, slc.datasource_type))
# add extra params for the import
slc.alter_params(
remote_id=slc.id,
datasource_name=slc.datasource.name,
schema=slc.datasource.name,
database_name=slc.datasource.database.name,
)
copied_dashboard.alter_params(remote_id=dashboard_id)
copied_dashboards.append(copied_dashboard)
eager_datasources = []
for dashboard_id, dashboard_type in datasource_ids:
eager_datasource = ConnectorRegistry.get_eager_datasource(
db.session, dashboard_type, dashboard_id)
eager_datasource.alter_params(
remote_id=eager_datasource.id,
database_name=eager_datasource.database.name,
)
make_transient(eager_datasource)
eager_datasources.append(eager_datasource)
return json.dumps({
'dashboards': copied_dashboards,
'datasources': eager_datasources,
}, cls=utils.DashboardEncoder, indent=4)