Executes a SELECT statement and returns the result set as a list of objects
513172
public <T extends DataObject> List<T> getResults(String name, DataObject object) throws Exception {
        @SuppressWarnings("unchecked")
        ObjectMappedQuery<T> statement = (ObjectMappedQuery<T>)_statements.get(name);
        if (statement != null) {
            return statement.getResults(DataSourceUtils.getConnection(_dataSource), object);
        } else {
            throw new RuntimeException("ObjectMappedQuery '" + name + "' not found");
        }
    }
928819
public ResultSet executeWithKeys() {
        context = startContext(connection(), metadata, entity);
        try {
            if (configuration.getTemplates().isNativeMerge()) {
                PreparedStatement stmt = null;
                if (batches.isEmpty()) {
                    stmt = createStatement(true);
                    listeners.notifyMerge(entity, metadata, keys, columns, values, subQuery);

                    listeners.preExecute(context);
                    stmt.executeUpdate();
                    listeners.executed(context);
                } else {
                    Collection<PreparedStatement> stmts = createStatements(true);
                    if (stmts != null && stmts.size() > 1) {
                        throw new IllegalStateException("executeWithKeys called with batch statement and multiple SQL strings");
                    }
                    stmt = stmts.iterator().next();
                    listeners.notifyMerges(entity, metadata, batches);

                    listeners.preExecute(context);
                    stmt.executeBatch();
                    listeners.executed(context);
                }

                final Statement stmt2 = stmt;
                ResultSet rs = stmt.getGeneratedKeys();
                return new ResultSetAdapter(rs) {
                    @Override
                    public void close() throws SQLException {
                        try {
                            super.close();
                        } finally {
                            stmt2.close();
                            reset();
                            endContext(context);
                        }
                    }
                };
            } else {
                if (hasRow()) {
                    // update
                    SQLUpdateClause update = new SQLUpdateClause(connection(), configuration, entity);
                    update.addListener(listeners);
                    populate(update);
                    addKeyConditions(update);
                    reset();
                    endContext(context);
                    return EmptyResultSet.DEFAULT;
                } else {
                    // insert
                    SQLInsertClause insert = new SQLInsertClause(connection(), configuration, entity);
                    insert.addListener(listeners);
                    populate(insert);
                    return insert.executeWithKeys();
                }
            }
        } catch (SQLException e) {
            onException(context,e);
            reset();
            endContext(context);
            throw configuration.translate(queryString, constants, e);
        }
    }
564036
def execute(self, statement):
        

        # Make the sql statement easier to read in case some of the queries we
        # run end up in the output
        sql = statement.replace('\n', '')
        sql = ' '.join(sql.split())
        self.cursor.execute(sql)

        return self.cursor.fetchall()
1249456
def execute(self, conn, transaction=False):
        
        sql = self.sql
        binds = {}
        
	cursors = self.dbi.processData(sql, binds, conn, transaction, returnCursor=True)
        result = []
        for c in cursors:
            result.extend(self.formatCursor(c, size=100))
        return result
35270
def get_resultsets(self, routine, *args):
        

        (query, replacements) = self.__build_raw_query(routine, args)

        # Grab a raw connection from the connection-pool.
        connection = mm.db.ENGINE.raw_connection()

        sets = []

        try:
            cursor = connection.cursor()

            cursor.execute(query, replacements)

            while 1:
                #(column_name, type_, ignore_, ignore_, ignore_, null_ok, column_flags)
                names = [c[0] for c in cursor.description]

                set_ = []
                while 1:
                    row_raw = cursor.fetchone()
                    if row_raw is None:
                        break

                    row = dict(zip(names, row_raw))
                    set_.append(row)

                sets.append(list(set_))

                if cursor.nextset() is None:
                    break

# TODO(dustin): nextset() doesn't seem to be sufficiant to tell the end.
                if cursor.description is None:
                    break
        finally:
            # Return the connection to the pool (won't actually close).
            connection.close()

        return sets
1269700
public Collector<T> getResults(Connection conn, DataObject object, Collector<T> collector) throws Exception {
        return executeSelect(conn, object, new ResultSetMapper<Collector<T>>(collector));
    }
514386
function _select (node, expr) {
        var
            resultSet,
            nodeSet = [node];
        while (expr) {
            resultSet = [];
            _test(nodeSet, expr, resultSet);
            if (0 === resultSet.length) {
                return [];
            }
            nodeSet = resultSet;
            if (expr.filter) {
                resultSet = [];
                _each(nodeSet, _filter, expr.filter, resultSet);
                if (0 === resultSet.length) {
                    return [];
                }
                nodeSet = resultSet;
            }
            expr = expr.then;
        }
        return resultSet;
    }
791485
def _executing(self, sql, params=[]):
        
        with self.connection() as connection:
            for row in connection.execute(sql, params):
                yield row
                if not self._db:
                    return
894292
def get(self, select):
        
        if is_list(select):
            return [(d[s] for s in select) for d in self.data]
        else:
            return [d[select] for d in self.data]
1012595
def execute_sql(self, statement):
        
        path = '/archive/{}/sql'.format(self._instance)
        req = archive_pb2.ExecuteSqlRequest()
        req.statement = statement

        response = self._client.post_proto(path=path,
                                           data=req.SerializeToString())
        message = archive_pb2.ExecuteSqlResponse()
        message.ParseFromString(response.content)
        if message.HasField('result'):
            return message.result
        return None
249851
static ResultSet executeStatement(SQL sql) throws SQLException {
    try (SqlSession session = sqlSessionFactory.openSession(true)) {
      try (Connection conn = session.getConnection()) {
        try (Statement stmt = conn.createStatement()) {
          return stmt.executeQuery(sql.toString());
        }
      }
    }
  }
869599
def execute(self, sql, values = ()) :
		""
		sql = sql.strip()
		self._debugActions(sql, values)
		cur = self.connection.cursor()
		cur.execute(sql, values)
		return cur
433969
public boolean evaluate(List<Object> objects, String sql) throws SQLException {
		synchronized (this) {
			String actualSql = sql == null ? this.sql : sql;
			PreparedStatement actualStmnt = null;
			try {
				actualStmnt = sql == null ? this.stmnt : prepareStatement(sql);

				this.objects = objects;
				actualStmnt.execute();
				ResultSet rs = actualStmnt.getResultSet();
				if (!rs.next()) {
					throw new IllegalArgumentException("Expected at least one returned row. SQL evaluated: " + actualSql);
				}
				boolean result = true;
				do {
					result &= rs.getBoolean(1);
				} while (rs.next());
				return result;
			} finally {
				if (sql != null && actualStmnt != null) {
					actualStmnt.close();
				}
			}
		}
	}
366472
def fetch_all_objects_from_db_where(self,
                                        cls: Type[T],
                                        table: str,
                                        fieldlist: Sequence[str],
                                        construct_with_pk: bool,
                                        wheredict: Optional[Dict[str, Any]],
                                        *args) -> List[T]:
        
        sql = (
            "SELECT " + ",".join([self.delimit(x) for x in fieldlist]) +
            " FROM " + self.delimit(table)
        )
        whereargs = []
        if wheredict is not None:
            sql += " WHERE " + " AND ".join([
                self.delimit(k) + "=?"
                for k in wheredict.keys()
            ])
            whereargs = wheredict.values()
        rows = self.fetchall(sql, *whereargs)
        objects = []
        for row in rows:
            objects.append(
                create_object_from_list(cls, fieldlist, row, *args,
                                        construct_with_pk=construct_with_pk))
        return objects
644469
function get_objects($sql, $class_name = 'stdClass', array $params = null, $index = null)
	{
		$result = array();
		$recset = $this->query($sql, MYSQLI_USE_RESULT);
		if (isset($index))
		{
			if (is_null($params))
				while ($obj = $recset->fetch_object($class_name))
					$result[$obj->$index] = $obj;
			else
				while ($obj = $recset->fetch_object($class_name, $params))
					$result[$obj->$index] = $obj;
		}
		else
		{
			if (is_null($params))
				while ($obj = $recset->fetch_object($class_name))
					$result[] = $obj;
			else
				while ($obj = $recset->fetch_object($class_name, $params))
					$result[] = $obj;
		}
		$recset->free_result();
		return $result;
	}
895491
def _setop(self, query):
        
        if isinstance(query.select, list):
            # RETURN BORING RESULT SET
            selects = FlatList()
            for s in listwrap(query.select):
                if isinstance(s.value, Mapping):
                    for k, v in s.value.items:
                        selects.append(sql_alias(v, quote_column(s.name + "." + k)))
                if isinstance(s.value, list):
                    for i, ss in enumerate(s.value):
                        selects.append(sql_alias(s.value, quote_column(s.name + "," + str(i))))
                else:
                    selects.append(sql_alias(s.value, quote_column(s.name)))

            sql = expand_template("""
                SELECT
                    {{selects}}
                FROM
                    {{table}}
                {{where}}
                {{sort}}
                {{limit}}
            """, {
                "selects": SQL(",\n".join(selects)),
                "table": self._subquery(query["from"])[0],
                "where": self._where2sql(query.where),
                "limit": self._limit2sql(query.limit),
                "sort": self._sort2sql(query.sort)
            })

            def post_process(sql):
                result = self.db.query(sql)
                for s in listwrap(query.select):
                    if isinstance(s.value, Mapping):
                        for r in result:
                            r[s.name] = {}
                            for k, v in s.value:
                                r[s.name][k] = r[s.name + "." + k]
                                r[s.name + "." + k] = None

                    if isinstance(s.value, list):
                        # REWRITE AS TUPLE
                        for r in result:
                            r[s.name] = tuple(r[s.name + "," + str(i)] for i, ss in enumerate(s.value))
                            for i, ss in enumerate(s.value):
                                r[s.name + "," + str(i)] = None

                expand_json(result)
                return result

            return sql, post_process  # RETURN BORING RESULT SET
        else:
            # RETURN LIST OF VALUES
            if query.select.value == ".":
                select = "*"
            else:
                name = query.select.name
                select = sql_alias(query.select.value, quote_column(name))

            sql = expand_template("""
                SELECT
                    {{selects}}
                FROM
                    {{table}}
                {{where}}
                {{sort}}
                {{limit}}
            """, {
                "selects": SQL(select),
                "table": self._subquery(query["from"])[0],
                "where": self._where2sql(query.where),
                "limit": self._limit2sql(query.limit),
                "sort": self._sort2sql(query.sort)
            })

            if query.select.value == ".":
                def post(sql):
                    result = self.db.query(sql)
                    expand_json(result)
                    return result

                return sql, post
            else:
                return sql, lambda sql: [r[name] for r in self.db.query(sql)]
478387
def fetchall(self, sql: str, *args) -> Sequence[Sequence[Any]]:
        """"""
        self.ensure_db_open()
        cursor = self.db.cursor()
        self.db_exec_with_cursor(cursor, sql, *args)
        try:
            rows = cursor.fetchall()
            return rows
        except:  # nopep8
            log.exception("fetchall: SQL was: " + sql)
            raise