Execute the query without fetching data. Returns the number of
elements in the query.
967206
def _execute_query(self):
        ''''''
        pipe = self.pipe
        if not self.card:
            if self.meta.ordering:
                self.ismember = getattr(self.backend.client, 'zrank')
                self.card = getattr(pipe, 'zcard')
                self._check_member = self.zism
            else:
                self.ismember = getattr(self.backend.client, 'sismember')
                self.card = getattr(pipe, 'scard')
                self._check_member = self.sism
        else:
            self.ismember = None
        self.card(self.query_key)
        result = yield pipe.execute()
        yield result[-1]
783753
def count(self):
        
        cmd = ("select COUNT(*) from {table} "
               "{join_clause}{where_clause}{order_clause}").format(
                    table=self.table_name,
                    where_clause=self.where_clause,
                    join_clause=self.join_clause,
                    order_clause=self.order_clause).rstrip()
        return Repo.db.execute(cmd, self.where_values)
1206386
def execute_sql(self, query):
        
        c = self.con.cursor()
        c.execute(query)
        result = []
        if c.rowcount > 0:
            try:
                result = c.fetchall()
            except psycopg2.ProgrammingError:
                pass
        return result
570610
def query(self, query, param=None):
        

        with self.conn.cursor() as curs:
            print 'XXX QUERY', curs.mogrify(query, param)
            try:
                curs.execute(query, param)
            except BaseException as exc:
                msg = 'query: {}, param: {}, exc: {}'.format(query, param, exc)

                if hasattr(exc, 'pgcode'):
                    msg = '{}, exc code: {}'.format(msg, exc.pgcode)

                print msg
                handle_exc(exc)

            result = curs.fetchall()

        return result
242580
def perfom_query(iterator_with_mapping, &block)
      iterator = perform_mapping? ? iterator_with_mapping : iterator_without_mapping(&block)
      connection.execute(aql_string, options).each(&iterator)
    end
1303295
def execute(self, limitRequest=350000, limitResMax=-1):
        """"""
        query = self.getQueries()
        query  = self.__buildLimit(query, limitResMax)
        nbr_results = limitResMax
        if (limitResMax == -1):
            query.setBaseUrl(self.__url+'/count')
            countUrl = query.getUrl()            
            result_count = Util.retrieveJsonResponseFromServer(countUrl)    
            nbr_results=result_count['total']
        else:
            nbr_results = limitResMax
        resultSearch = []
        if nbr_results < limitRequest :            
            query.setBaseUrl(self.__url+'/records')
            url = query.getUrl()
            startVal = query._getParameters()['start']
            while (nbr_results-startVal)>0 :#Do the job per 300 items till nbr_result is reached                
                resultTemp = Util.retrieveJsonResponseFromServer(url)
                resultSearch.extend(self.__parseResponse(resultTemp))
                parameters = query._getParameters()                
                startVal = parameters['start'] + parameters['limit']
                query = UpdateParameter(query, 'start', startVal) 
                query.setBaseUrl(self.__url+'/records')
		url=query.getUrl()            
        else:
            out_mess="Not allowed\nNbr results (%d) exceeds limit_request param: %d\n" % (nbr_results, limitRequest)
            self.__logger.info(out_mess)        
        return resultSearch
175309
protected function _performCount()
    {
        $query = $this->cleanCopy();
        $counter = $this->_counter;
        if ($counter) {
            $query->counter(null);

            return (int)$counter($query);
        }

        $complex = (
            $query->clause('distinct') ||
            count($query->clause('group')) ||
            count($query->clause('union')) ||
            $query->clause('having')
        );

        if (!$complex) {
            // Expression fields could have bound parameters.
            foreach ($query->clause('select') as $field) {
                if ($field instanceof ExpressionInterface) {
                    $complex = true;
                    break;
                }
            }
        }

        if (!$complex && $this->_valueBinder !== null) {
            $order = $this->clause('order');
            $complex = $order === null ? false : $order->hasNestedExpression();
        }

        $count = ['count' => $query->func()->count('*')];

        if (!$complex) {
            $query->getEagerLoader()->enableAutoFields(false);
            $statement = $query
                ->select($count, true)
                ->enableAutoFields(false)
                ->execute();
        } else {
            $statement = $this->getConnection()->newQuery()
                ->select($count)
                ->from(['count_source' => $query])
                ->execute();
        }

        $result = $statement->fetch('assoc')['count'];
        $statement->closeCursor();

        return (int)$result;
    }
944704
def sql(self, query):
        
        # Get the schema by adding a LIMIT 0 on to the end of the query. If
        # there is already a limit in the query, we find and remove it
        limited_query = 'SELECT * FROM ({}) t0 LIMIT 0'.format(query)
        schema = self._get_schema_using_query(limited_query)
        return ops.SQLQueryResult(query, schema, self).to_expr()
1019508
def count(self, query):
        
        body = {
            "query": {
                "bool": {
                    "must": [{
                        "query_string": {
                            "query": query,
                        }
                    }]
                }
            }
        }

        body['query']['bool']['must'].append(self._get_timestamp_filer())

        return self._es.count(index=self._index, body=body).get('count')
93870
def count(self, sqlTail = '') :
		""
		sql, sqlValues = self.getSQLQuery(count = True)
		return int(self.con.execute('%s %s'% (sql, sqlTail), sqlValues).fetchone()[0])
150240
def execute(self, query_string, params=None):
    
    cr = self.connection.cursor()
    logger.info("SQL: %s (%s)", query_string, params)
    self.last_query = (query_string, params)
    t0 = time.time()
    cr.execute(query_string, params or self.core.empty_params)
    ms = (time.time() - t0) * 1000
    logger.info("RUNTIME: %.2f ms", ms)
    self._update_cursor_stats(cr)
    return cr
530782
def query(self, **options):
        ''''''
        if not self._query_path:
            raise AttributeError('query is not available for %s' % self._item_name)
        last_item = 0
        offset = 0
        current_item = None
        limit = options.get('limit', 25)
        options['limit'] = limit
        target = self._query_path
        while True:
            options['offset'] = offset
            # go get the data with the given offset
            json_data = self._redmine.get(target, options)
            # Try and read the json
            try:
                data = json.loads(json_data)
            except:
                raise RedmineError(json_data)

            # The data is enclosed in the _query_container item
            # That is, {'issues':{(issue1),(issue2)...}, 'total_count':##}
            data_container = data[self._query_container]
            for item_data in data_container:
                yield(self._objectify(data=item_data))

            # If the container was empty, we requested past the end, just exit
            if not data_container:
                break
            try:
                if int(data['total_count']) > ( offset + len(data_container) ):
                    # moar data!
                    offset += limit
                else:
                    break
            except:
                # If we don't even have a 'total_count', we're done.
                break
94163
def execute_query(self, query, session):
		'''  '''
		self.auto_ensure_indexes(query.type)

		kwargs = dict()
		if query._get_fields():
			if PYMONGO_3: # pragma: nocover
				kwargs['projection'] = query._fields_expression()
			else: # pragma: nocover
				kwargs['fields'] = query._fields_expression()

		collection = self.db[query.type.get_collection_name()]
		
		if query._search:
			index_fields = query._createIndex
			if index_fields:
				# create new index
				if type(index_fields) is list:
					index_list = []
					for field in index_fields:
						index_list.append ((field, pymongo.TEXT))
					collection.create_index(index_list, name='search_index', default_language='english')
				else:
					raise InvalidConfigException()
			cursor = collection.find(query.query, {'__index_score': {'$meta': "textScore"}}, **kwargs)
			cursor.sort([('__index_score', {'$meta': 'textScore'})])
		elif query._rawquery:
			if query._query_type=='aggregate':
				cursor = collection.aggregate(query.query, cursor={}, **kwargs)
			elif query._query_type=='map_reduce':
				cursor = collection.map_reduce( query._mapreduce_mapper, query._mapreduce_reducer, query._mapreduce_key, query=query._mapreduce_query)
		else:
			cursor = collection.find(query.query, **kwargs)

		if query._sort:
			cursor.sort(query._sort)
		elif query.type.config_default_sort:
			cursor.sort(query.type.config_default_sort)
		if query.hints:
			cursor.hint(query.hints)
		if query._get_limit() is not None:
			cursor.limit(query._get_limit())
		if query._get_skip() is not None:
			cursor.skip(query._get_skip())
		return QueryResult(session, cursor, query.type, raw_output=query._raw_output, fields=query._get_fields())
706182
def get_count_query(self):
        
        query_copy = self.copy()
        if not query_copy.tables:
            raise Exception('No tables specified to do a count')

        for table in query_copy.tables:
            del table.fields[:]

        query_copy.tables[0].add_field(CountField('*'))
        del query_copy.sorters[:]
        return query_copy
148944
def count_row(engine, table):
    
    return engine.execute(select([func.count()]).select_from(table)).fetchone()[0]
739381
public int count() {
		Integer result = null;
		if (result == null) {
			SimpleQuery q = this.isKeysOnly()? this : this.clone().keysOnly();
			result = getDatastoreService().prepare(q.getQuery()).countEntities(fetchOptions);
		}
		return result;
	}
1169698
def getquery(query):
	''
	try:
		conn = connection.cursor()
		conn.execute(query)
		data = conn.fetchall()
		conn.close()
	except: data = list()
	return data