示例#1
0
def get_partition_by_name(cursor, name):
    column_names = [
        "table_name", "datasource_id", "entitytype_id", "granularity",
        "data_start", "data_end"]
    columns = map(Column, column_names)

    query = schema.partition.select(columns, where_=Eq(Column("table_name")))

    args = name,

    query.execute(cursor, args)

    if cursor.rowcount > 0:
        name, datasource_id, entitytype_id, granularity_str, data_start, \
                data_end = cursor.fetchone()

        granularity = create_granularity(str(granularity_str))
        datasource = get_datasource_by_id(cursor, datasource_id)
        entitytype = get_entitytype_by_id(cursor, entitytype_id)

        trendstore = TrendStore(datasource, entitytype, granularity)

        return Partition(name, trendstore, data_start, data_end)
    else:
        return None
    def load_attributestore(cls, cursor, id, datasource_id, entitytype_id):
        datasource = get_datasource_by_id(cursor, datasource_id)
        entitytype = get_entitytype_by_id(cursor, entitytype_id)

        attributestore = AttributeStore(datasource, entitytype)
        attributestore.id = id
        attributestore.attributes = attributestore.load_attributes(cursor)

        return attributestore
示例#3
0
def view_source_from_row(cursor, row):
    id, name, datasource_id, entitytype_id, granularity = row

    view_source = ViewSource()
    view_source.id = id
    view_source.name = name
    view_source.datasource = get_datasource_by_id(cursor, datasource_id)
    view_source.entitytype = get_entitytype_by_id(cursor, entitytype_id)
    view_source.granularity = granularity
    return view_source
示例#4
0
def view_from_row(cursor, row):
    id, description, datasource_id, entitytype_id, granularity, sql = row

    view = View()
    view.id = id
    view.sql = sql
    view.description = description
    view.datasource = get_datasource_by_id(cursor, datasource_id)
    view.entitytype = get_entitytype_by_id(cursor, entitytype_id)
    view.granularity = create_granularity(granularity)

    view.sources = get_sources_for_view(cursor, id)

    return view
    def get(cls, cursor, id):
        """Load and return attributestore by its Id."""
        query = (
            "SELECT datasource_id, entitytype_id "
            "FROM attribute_directory.attributestore "
            "WHERE id = %s")
        args = id,
        cursor.execute(query, args)

        datasource_id, entitytype_id = cursor.fetchone()

        entitytype = get_entitytype_by_id(cursor, entitytype_id)
        datasource = get_datasource_by_id(cursor, datasource_id)

        attributestore = AttributeStore(datasource, entitytype)
        attributestore.id = id
        attributestore.attributes = attributestore.load_attributes(cursor)

        return attributestore
示例#6
0
    def get_by_id(cls, cursor, id):
        args = (id,)

        cls.get_by_id_query.execute(cursor, args)

        if cursor.rowcount == 1:
            trendstore_id, datasource_id, entitytype_id, granularity_str, \
                    partition_size, type, version = cursor.fetchone()

            datasource = get_datasource_by_id(cursor, datasource_id)
            entitytype = get_entitytype_by_id(cursor, entitytype_id)

            granularity = create_granularity(granularity_str)

            trendstore = TrendStore(datasource, entitytype, granularity,
                    partition_size, type)

            trendstore.id = trendstore_id

            return trendstore