Starts a SELECT query for a qualified table.
347217
@NonNull
  public static SelectFrom selectFrom(
      @Nullable CqlIdentifier keyspace, @NonNull CqlIdentifier table) {
    return new DefaultSelect(keyspace, table);
  }
192239
def _construct_select_query(**filter_definition):
    
    table_name = filter_definition.pop('table')
    distinct = filter_definition.pop('distinct', False)
    select_count = filter_definition.pop('count', False)

    if distinct and select_count:
        raise UnsupportedDefinitionError('SELECT (DISTINCT ...) is not supported')

    if select_count and 'select' in filter_definition:
        raise UnsupportedDefinitionError('SELECT COUNT(columns) is not supported')

    if 'joins' in filter_definition:
        join_definitions = filter_definition.pop('joins')

        if not isinstance(join_definitions, (tuple, list)):
            join_definitions = (join_definitions,)

        filter_definition['joins'] = []
        for join_def in join_definitions:
            filter_definition['joins'].append(_expand_join(join_def))

    if 'where' in filter_definition:
        for key, value in filter_definition['where'].items():
            if is_filter_query(value):
                # We can do it recursively here
                sub_query = value.pop(DEFAULT_FILTER_KEY)
                if value:
                    raise ParsingInputError("Unknown keys for sub-query provided: %s" % value)
                filter_definition['where'][key] = mosql_raw('( {} )'.format(_construct_select_query(**sub_query)))
            elif isinstance(value, str) and value.startswith('$') and QUERY_REFERENCE.fullmatch(value[1:]):
                # Make sure we construct correct query with escaped table name and escaped column for sub-queries
                filter_definition['where'][key] = mosql_raw('"{}"'.format('"."'.join(value[1:].split('.'))))

    raw_select = select(table_name, **filter_definition)

    if distinct:
        # Note that we want to limit replace to the current SELECT, not affect nested ones
        raw_select = raw_select.replace('SELECT', 'SELECT DISTINCT', 1)
    if select_count:
        # Note that we want to limit replace to the current SELECT, not affect nested ones
        raw_select = raw_select.replace('SELECT *', 'SELECT COUNT(*)', 1)

    return raw_select
534817
def excute_query(query, db=None, flags=None, use_sudo=False, **kwargs):
    """"""

    flags = flags or u''
    if db:
        flags = u"%s -d %s" % (flags, db)
    command = u'psql %s -c "%s"' % (flags, query)
    if use_sudo:
        sudo(command, user='postgres', **kwargs)
    else:
        run(command, **kwargs)
501914
public FutureData<DataSiftResult> start(FutureData<PreparedHistoricsQuery> query) {
        if (query == null) {
            throw new IllegalArgumentException("A valid PreparedHistoricsQuery is required");
        }
        final FutureData<DataSiftResult> future = new FutureData<>();
        DataSiftResult h = new BaseDataSiftResult();

        FutureResponse<PreparedHistoricsQuery> r = new FutureResponse<PreparedHistoricsQuery>() {
            public void apply(PreparedHistoricsQuery data) {
                if (data.getId() == null || data.getId().isEmpty()) {
                    throw new IllegalArgumentException("A valid PreparedHistoricsQuery is required");
                }
                start(data.getId(), future);
            }
        };
        unwrapFuture(query, future, h, r);
        return future;
    }
166024
def select(self, to_select, where=None, sql_params=None):
        '''
        
        '''
        if sql_params is None:
            sql_params = []
        query = '''
        SELECT %s FROM %s
        ''' % (to_select, self._name)
        if where:
            query = '%s WHERE %s' % (query, where)
        return self._cursor.execute(query, tuple(sql_params))
1108023
def compile_create_table(qualified_name: str, column_statement: str,
                         primary_key_statement: str) -> str:
    """"""

    statement = """
                CREATE TABLE {table} ({columns} {primary_keys});
                """.format(table=qualified_name,
                           columns=column_statement,
                           primary_keys=primary_key_statement)
    return statement
554275
function select( $table, $options = array() ) {

        $options = array_merge( array(

            'expr' => null,
            'where' => array(),
            'orderBy' => array(),
            'limitCount' => null,
            'limitOffset' => null,
            'params' => array()

        ), $options );

        $query = "SELECT ";

        if ( empty( $options[ 'expr' ] ) ) {

            $query .= "*";

        } else if ( is_array( $options[ 'expr' ] ) ) {

            $query .= implode( ", ", $options[ 'expr' ] );

        } else {

            $query .= $options[ 'expr' ];

        }

        $table = $this->rewriteTable( $table );
        $query .= " FROM " . $this->quoteIdentifier( $table );

        $query .= $this->getSuffix( $options[ 'where' ], $options[ 'orderBy' ], $options[ 'limitCount' ], $options[ 'limitOffset' ] );

        $this->onQuery( $query, $options[ 'params' ] );

        $statement = $this->prepare( $query );
        $statement->setFetchMode( \PDO::FETCH_ASSOC );
        $statement->execute( $options[ 'params' ] );

        return $statement;

    }
89043
static function select(\fenrir\system\MysqlDatabaseSignature $db, $table, $constraints = null) {
		$constraints !== null or $constraints = '1';
		return $db->prepare
			(
				"
					SELECT *
					  FROM `$table`
					 WHERE $constraints
				"
			)
			->execute()
			->fetch_all();
	}
1274700
protected function _buildSelectStart()
        {
            $fragment = 'SELECT ';
            $result_columns = join(', ', $this->_resultColumns);

            if (!is_null($this->_limit) &&
                self::$_config[$this->_connection_name]['limit_clause_style'] === One::LIMIT_STYLE_TOP_N) {
                $fragment .= "TOP {$this->_limit} ";
            }

            if ($this->_distinct) {
                $result_columns = 'DISTINCT ' . $result_columns;
            }

            $fragment .= "{$result_columns} FROM " . $this->_quoteIdentifier($this->_table_name);

            if (!is_null($this->_table_alias)) {
                $fragment .= " " . $this->_quoteIdentifier($this->_table_alias);
            }

            return $fragment;
        }
697492
def selectisinstance(table, field, value, complement=False):
    """"""

    return selectop(table, field, value, isinstance, complement=complement)
138920
function SqlSelect (model, args) {
    // capture input
    this.model = model
    this.args = _.cloneDeep(args)
    // make sure where is defined in args
    this.args.where = requireValidOptionalObject(this.args.where)

    // map of alias => table
    this.aliases = {}
    // map of table => alias - since the same table can be used multiple times
    // in query the canonical alias for a table is the one that data is being
    // selected from 
    this.tableAliases = {}

    // primary table name
    this.table = model.name
    // primary table alias
    this.alias = this.getAlias(this.table)

    // list of related model names joined on
    this.joinRelationNames = []
    // map of related models joined on with join config
    this.joinRelations = {}

    // list of columns to select
    this.select = []
    // list of join statements
    this.join = []
    // list of where statements
    this.where = []
    // list of order statements
    this.order = []
    // limit for query
    this.limit = undefined
    // offset for query
    this.offset = undefined

    // params for query placeholder => value
    this.params = {}

    // check if query is select by id
    this.checkSelectById()
    // check if query should select only ids
    this.checkSelectOnlyIds()

    // execute simple selectById if this is an id query with no extra flags
    if (this.isSelectById) {
        this.selectById()
    }
    // execute generic query builder
    else {
        // add access control checks
        this.addAccessControl()
        // build joins on relations
        this.buildJoinRelations()
        // build list of columns from the primary table to select
        this.buildSelect()
        // get the queried revision(s) of objects
        this.buildRevision()
        // build where args
        _.each(this.args.where, (value, name) => this.buildWhere(name, value))
        // build order args
        this.buildOrder()
        // build full sql SELECT statement
        this.buildSql()
    }
}
685996
public function select(
        $table,
        $conditions = null,
        $fields = null,
        $order = null,
        $limit = null,
        $offset = null
    )
    {
        if (is_null($fields)) {
            $fields = "*";
        }

        $queryString = "SELECT {$fields} FROM {$table} ";

        if (!is_null($conditions)) {
            $queryString .= "WHERE {$conditions} ";
        }

        if (!is_null($order)) {
            $queryString .= "ORDER BY {$order} ";
        }

        if (!is_null($limit)) {
            $queryString .= "LIMIT {$limit} ";
        }

        if (!is_null($offset) && !is_null($limit)) {
            $queryString .= "OFFSET {$offset} ";
        }


        $queryString .= ";";

        $this->query($queryString);

        return $this->countRows();
    }
1258295
def _execute_select_commands(self, source, commands):
        """"""
        rows = {}
        for tbl, command in tqdm(commands, total=len(commands), desc='Executing {0} select queries'.format(source)):
            # Add key to dictionary
            if tbl not in rows:
                rows[tbl] = []
            rows[tbl].extend(self.fetch(command, commit=True))
        self._commit()
        return rows
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)]
964392
def prepare_sql(sql, add_semicolon=True, invalid_starts=('--', '/*', '*/', ';')):
    """"""
    return PrepareSQL(sql, add_semicolon, invalid_starts).prepared
692865
def select(first_or_all, sql_params = "", *bindvars)
      case first_or_all
      when :first, :all
        select_sql = "SELECT * "
      when :count
        select_sql = "SELECT COUNT(*) "
      else
        raise ArgumentError, "Only :first, :all or :count are supported"
      end
      select_sql << "FROM \"#{@schema_name}\".\"#{@table_name}\" "
      case sql_params
      when String
        select_sql << sql_params
      when Hash
        raise ArgumentError, "Cannot specify bind variables when passing WHERE conditions as Hash" unless bindvars.empty?
        where_sqls = []
        order_by_sql = nil
        sql_params.each do |k, v|
          if k == :order_by
            order_by_sql = " ORDER BY #{v} "
          elsif v.nil? || v == :is_null
            where_sqls << "#{k} IS NULL"
          elsif v == :is_not_null
            where_sqls << "#{k} IS NOT NULL"
          else
            where_sqls << "#{k} = :#{k}"
            bindvars << v
          end
        end
        select_sql << "WHERE " << where_sqls.join(" AND ") unless where_sqls.empty?
        select_sql << order_by_sql if order_by_sql
      else
        raise ArgumentError, "Only String or Hash can be provided as SQL condition argument"
      end
      if first_or_all == :count
        @schema.select_one(select_sql, *bindvars)
      else
        @schema.select(first_or_all, select_sql, *bindvars)
      end
    end
671914
private void validateSelectQuery(final String selectQuery) {
        final SimpleDBParser parser = new SimpleDBParser(selectQuery);
        try {
            parser.selectQuery();
        } catch (Exception e) {
            throw new InvalidSimpleDBQueryException("The following query is an invalid SimpleDB query: " + selectQuery,
                    e);
        }
    }