コード例 #1
0
    def test_views(self):
        """test views """
        metadata = load_from_file("complex_db.yaml")
        person_name = find_table_name(metadata, 'Person')
        (view, _) = make_view_without_table(metadata,
                   person_name, 'FullName')
#        process_dataset = find_table(view, 'ProcessedDatasetView')
#        data_tier = find_table(view, 'DataTierView')
#        process_dataset = find_table(view, 'PrimaryDatasetView')
#        files = find_table(view, 'FilesView')

        # This shows what happens to the foreign keys
        #      when you make a select statement.
        for table_name in view.tables:
            table = view.tables[table_name]
            for f_key in table.foreign_keys:
                vals = {}
                vals['table'] = table_name
                vals['column'] = f_key.parent.name
                if f_key.parent.table.__dict__.has_key('name'):
                    vals['from'] = f_key.parent.table.name
                else:
                    vals['from'] = "none"
                if f_key.column.table.__dict__.has_key('name'):
                    vals['to'] = f_key.column.table
                else:
                    vals['to'] = "none"
                _LOGGER.debug(
                    "test_views %(table)s.%(column)s %(from)s->%(to)s"
                    % vals)
コード例 #2
0
    def test_view_build(self):
        """test view build """
        _LOGGER.debug("test_view_build start")
        metadata = load_from_file("complex_db.yaml")
        person_name = find_table_name(metadata, 'Person')
        (view, foreign_keys) = make_view_without_table(metadata,
                                 person_name, 'FullName')
#        for table_name in view.tables:
#            print table_name, list(view.tables[table_name].c)
#        files = find_table(view, 'FilesView')
        process_dataset = find_table(view, 'ProcessedDatasetView')
        data_tier = find_table(view, 'DataTierView')
        process_dataset = find_table(view, 'PrimaryDatasetView')
        query_builder = Schema(view.tables, foreign_keys)
        select_test = select([process_dataset.c.Name, data_tier.c.Name,
                             process_dataset.c.Description],
            process_dataset.c.ID==0)
        query = query_builder.build_query(select_test)
        _LOGGER.debug("test_view_build query: " + str(query))
        _LOGGER.debug("test_view_build finish")
コード例 #3
0
    def test_live_view(self):
        """ test live views"""
        _LOGGER.debug("test_live_view start")
        metadata = self.metadata
        person_name = find_table_name(metadata, 'Person')
        (view, foreignkeys) = make_view_without_table(metadata,
                              person_name, 'DistinguishedName')
#        for table_name in view.tables:
#            print table_name, list(view.tables[table_name].c)
        process_dataset = find_table(view, 'ProcessedDatasetView')
        app_exec = find_table(view, 'AppExecutableView')
        select_test = select([process_dataset.c.Name,
                              app_exec.c.ExecutableName])
        query_builder = Schema(view.tables, foreignkeys)
        query = query_builder.build_query(select_test)
#        print "test_live_view query:", query
        results = query.execute()
        rows = results.fetchall()

        _LOGGER.debug("test_live_view query: " + str(query))
        _LOGGER.debug("test_live_view result: %s" % (rows,))
#        print "test_live_view result: %s" % (rows,)
        _LOGGER.debug("test_live_view finish")