#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2023/4/9 14:41 # @Author : old tom # @File : metadata_warehouse.py # @Project : futool-tiny-datahub # @Desc : 元数据存储 from common.futool.fu_id import id_gen from datahub.metadata.metadatadao.metadata_dao import MetadataDao from datahub.local_db_conf import local_conn class MetadataWareHouse(object): """ 元数据仓库 """ def __init__(self, source_id): self.source_id = source_id self.dao = MetadataDao(local_conn) def save_metadata_obj(self, objs, obj_type): """ 保存元数据对象 :param obj_type: 元数据类型 :param objs: :return: """ data = [(id_gen.get_id(), self.source_id, obj_type, x[0], x[1]) for x in objs] return self.dao.save_metadata_obj(data) def save_metadata_obj_detail(self, details): """ 保存元数据对象明细 :param details: :return: """ return self.dao.save_metadata_create(details) def save_metadata_obj_field(self, fields): """ 保存字段 :param fields: :return: """ return self.dao.save_table_fields(fields) def query_metadata(self, obj_type=None): """ 查询元数据 :param obj_type: :return: """ return self.dao.query_metadata_by_type(obj_type) def query_metadata_name(self, obj_type=None): """ 查询元数据名称 :param obj_type: :return: """ return self.dao.query_metadata_name_by_type(obj_type) def query_metadata_id_name(self, obj_type=None): """ 查询元数据ID及名称 :param obj_type: :return: """ return self.dao.query_metadata_id(obj_type)