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
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]
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
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