Next / Previous / Contents / NM Tech homepage

6.24. CBCData.genRegionCircles()
# - - -   C B C D a t a . g e n R e g i o n C i r c l e s

    def genRegionCircles(self, regionCode):
        '''Generate circles that use the given regionCode

This query requires that we refer to columns in a related table, cir_regs, and filter out circles that are not related to the given regionCode. The .join() method adds the columns from the cir_reg table, and the .filter_by() method includes only those rows in the joined table whose reg_code column equals regionCode. The .order_by() method sorts the resulting rows by circle name.
        q = ( self.s.query(self.Circle)
               .order_by('cir_name') )
        for circle in q:
            yield circle