def select(self, return_models=False, nest=False, bypass_safe_limit=False, sql=None, sql_args=None):
        # Check if we need to set a safe limit
        if bypass_safe_limit is False:
            if Query.enable_safe_limit:
                if self.count() > Query.safe_limit:
                    self.limit(Query.safe_limit)

        # determine which sql to use
        if sql is None:
            sql = self.get_sql()

        # determine which sql args to use
        if sql_args is None:
            sql_args = self.get_args()

        # get the cursor to execute the query
        cursor = self.get_cursor()

        # execute the query
        cursor.execute(sql, sql_args)

        # get the results as a list of dictionaries
        rows = self._fetch_all_as_dict(cursor)

        # check if models should be returned instead of dictionaries
        if return_models:

            # set nesting to true, so the nested models can easily load the data
            nest = True

            # build model map of map name to model
            model_map = {}
            for join_item in self.joins:
                model_map[join_item.right_table.field_prefix] = join_item.right_table.model

        # check if results should be nested
        if nest:

            # convert keys with double underscores to dictionaries
            for row in rows:
                _row = row.copy()
                for key, value in _row.items():
                    set_value_for_keypath(row, key, value, True, '__')
                    if '__' in key:
                        row.pop(key)

            # create models if needed
            if return_models:
                model_class = self.tables[0].model
                new_rows = []
                for row in rows:
                    model = model_class()
                    # assign all non-model keys first because django 1.5 requires
                    # that the model has an id set before setting a property that is
                    # a foreign key
                    for key, value in row.items():
                        if key not in model_map:
                            setattr(model, key, value)
                    # assign all model instances
                    for key, value in row.items():
                        if key in model_map:
                            child_model = model_map[key]()
                            for child_key, child_value in value.items():
                                setattr(child_model, child_key, child_value)
                            value = child_model
                        setattr(model, key, value)
                    new_rows.append(model)
                rows = new_rows

        return rows
HTTP authentication data as a (user, password) tuple. This
dataset/ETHPy150Open ambitioninc/django-query-builder/querybuilder/query.py/Query.select--crossover with--dataset/ETHPy150Open adampresley/bottlepy-bootstrap/app/bottle.py/BaseRequest.auth