示例#1
0
文件: __init__.py 项目: 01-/grano
 def count(self):
     """ Get a count of the number of distinct objects. """
     q = select(from_obj=self.join(self.alias))
     q = self.filter(q, partial=True)
     q = q.column(func.count(func.distinct(self.alias.c.id)).label('num'))
     rp = db.session.execute(q)
     return rp.fetchone().num
示例#2
0
 def count(self):
     """ Get a count of the number of distinct objects. """
     q = select(from_obj=self.join(self.alias))
     q = self.filter(q, partial=True)
     q = q.column(func.count(func.distinct(self.alias.c.id)).label('num'))
     rp = db.session.execute(q)
     return rp.fetchone().num
示例#3
0
 def num_entries(self, conditions="1=1"):
     """ Return the count of entries on the dataset fact table having the
     dimension set to a value matching the filter given by ``conditions``.
     """
     query = select([func.count(func.distinct(self.column_alias))],
                    conditions)
     rp = self.dataset.bind.execute(query)
     return rp.fetchone()[0]
示例#4
0
 def num_entries(self, conditions="1=1"):
     """ Return the count of entries on the model fact table having the
     dimension set to a value matching the filter given by ``conditions``.
     """
     query = select([func.count(func.distinct(self.column_alias))],
                    conditions)
     rp = self.model.bind.execute(query)
     return rp.fetchone()[0]
def allUpdatesSeriesSource():
    A = db.sequence_series2_updates.alias(name="A")

    series = db.connection.execute( sql.select((func.distinct(A.c.source),)).where(
        A.c.dummy_id > args.start_from_id) ).fetchall()
    # yield 505 # test only
    
    for s in [x[0] for x in series]:
        yield s
示例#6
0
文件: app.py 项目: hamimhamim21/Terry
def get_column_values(for_column, selected_region=None):
    """
    Let's get the unique distinct values from column in
    our database, optionally filtering by query string.
    """

    value_query = db.session.query(
        func.distinct(getattr(Breweries, for_column)))

    if selected_region is not None:
        value_query = value_query.filter(Breweries.region == selected_region)

    values = sorted([x[0] for x in value_query.all()])

    return values