Single Database Query
190645
def db(self, request):
        ''''''
        with self.mapper.begin() as session:
            world = session.query(World).get(randint(1, 10000))
        return Json(self.get_json(world)).http_response(request)
932797
def query_fetch_all(self, query, values):
        
        self.cursor.execute(query, values)
        retval = self.cursor.fetchall()
        self.__close_db()
        return retval
651280
def query(sql, options=nil) #:nodoc:
      raise ArgumentError, 'query is blank' if blank? sql

      options_pattern = { :limit => :optional }
      verify_options(options, options_pattern) unless options.nil?

      limit = ''
      limit = "/#{options[:limit]}" if !options.nil? and options.include?(:limit)

      response = call_server(:method => :get, :uri => "query/#{@database}/sql/#{CGI::escape(sql)}#{limit}")
      entries = process_response(response) do
        raise NotFoundError, 'record not found' if response.body =~ /ORecordNotFoundException/
      end

      rslt = entries['result']
      # mixin all document entries (they have '@class' attribute)
      rslt.each { |doc| doc.extend Orientdb4r::DocumentMetadata unless doc['@class'].nil? }
      rslt
    end
1337542
def _sql(self, sql: str, params=()):
        
        statement = SingleSqlStatement(sql)
        return self.statement(statement).execute_for_params(params).cursor
83601
def namedb_query_execute( cur, query, values, abort=True):
    
    return db_query_execute(cur, query, values, abort=abort)
310827
def query_all(**kwargs):
        '''
        
        '''
        kind = kwargs.get('kind', '1')
        limit = kwargs.get('limit', 10)

        return TabPost.select().where(
            (TabPost.kind == kind) &
            (TabPost.valid == 1)
        ).order_by(
            TabPost.time_update.desc()
        ).limit(limit)
1303643
def get_database(obj, **params):
    """"""
    if isinstance(obj, string_types):
        return connect(obj, **params)
    return obj
1075027
def query_under_condition(condition, kind='2'):
        '''
        
        '''
        if DB_CFG['kind'] == 's':
            return TabPost.select().where(
                (TabPost.kind == kind) & (TabPost.valid == 1)
            ).order_by(
                TabPost.time_update.desc()
            )

        return TabPost.select().where(
            (TabPost.kind == kind) &
            (TabPost.valid == 1) &
            TabPost.extinfo.contains(condition)
        ).order_by(TabPost.time_update.desc())
1277989
public static function findAllBySql($sql,$data=[],$db_name=''){
		# example: $sql = 'SELECT * FROM  sales_flat_quote';
		$db = self::getDb($db_name);
		$result = $db->createCommand($sql,$data)
					->queryAll();
		return $result;
	}
1169698
def getquery(query):
	''
	try:
		conn = connection.cursor()
		conn.execute(query)
		data = conn.fetchall()
		conn.close()
	except: data = list()
	return data
421112
def query(query, args_or_dbname, params = {})
      query = transmute_data(query)
      args = args_or_dbname.is_a?(String) ? [db_alias(args_or_dbname)] : args_or_dbname
      args = transmute_data(args)
      get root_url("api/query"), params.merge(:q => query, :args => args)
    end
287769
def query(self, req, timeout=None, metadata=None, credentials=None):
        """"""
        return self.stub.Query(req, timeout=timeout, metadata=metadata,
                               credentials=credentials)
870682
def query(self, query, *parameters, **kwargs):
        """"""
        cursor = self._cursor()
        try:
            self._execute(cursor, query, parameters or None, kwargs)
            if cursor.description:
                column_names = [column.name for column in cursor.description]
                res = [Row(zip(column_names, row)) for row in cursor.fetchall()]
                cursor.close()
                return res
        except:
            cursor.close()
            raise
220627
function _query($sql,$inputarr=false)
	{
		$rez = $this->_connectionID->query($sql);
		if ($rez === false) {
			$this->_errorNo = $this->_connectionID->lastErrorCode();
		}
		// If no data was returned, we don't need to create a real recordset
		elseif ($rez->numColumns() == 0) {
			$rez->finalize();
			$rez = true;
		}

		return $rez;
	}
563755
def query_obj(self):
        """"""
        d = super().query_obj()
        d['row_limit'] = self.form_data.get(
            'row_limit', int(config.get('VIZ_ROW_LIMIT')))
        numeric_columns = self.form_data.get('all_columns_x')
        if numeric_columns is None:
            raise Exception(_('Must have at least one numeric column specified'))
        self.columns = numeric_columns
        d['columns'] = numeric_columns + self.groupby
        # override groupby entry to avoid aggregation
        d['groupby'] = []
        return d
698843
function _query($sql,$inputarr=false)
	{
		$rez = sqlite_query($sql,$this->_connectionID);
		if (!$rez) {
			$this->_errorNo = sqlite_last_error($this->_connectionID);
		}
		// If no data was returned, we don't need to create a real recordset
		// Note: this code is untested, as I don't have a sqlite2 setup available
		elseif (sqlite_num_fields($rez) == 0) {
			$rez = true;
		}

		return $rez;
	}
1244406
public TResult queryForAll() {
		TResult result = userDb.query(getTableName(), table.getColumnNames(),
				null, null, null, null, null);
		prepareResult(result);
		return result;
	}