Select between these operations on the database
777493
def operate_menu():
    ""

    selection = True
    while selection:

        print globals()['operate_menu'].__doc__
        selection = select([
            'chill.database functions',
            'execute sql file',
            'render_node',
            'New collection',
            'Manage collection',
            'Add document for node',
            'help',
            ])
        if selection == 'chill.database functions':
            mode_database_functions()
        elif selection == 'execute sql file':
            print "View the sql file and show a fill in the blanks interface with raw_input"
            sqlfile = choose_query_file()
            if not sqlfile:
                # return to the menu choices if not file picked
                selection = True
            else:
                sql_named_placeholders_re = re.compile(r":(\w+)")
                sql = fetch_query_string(sqlfile)
                placeholders = set(sql_named_placeholders_re.findall(sql))
                print sql
                data = {}
                for placeholder in placeholders:
                    value = raw_input(placeholder + ': ')
                    data[placeholder] = value

                result = []
                try:
                    result = db.execute(text(sql), data)
                except DatabaseError as err:
                    current_app.logger.error("DatabaseError: %s", err)

                if result and result.returns_rows:
                    result = result.fetchall()
                    print result
                    if not result:
                        print 'No results.'
                    else:
                        kw = result[0]

                        if 'node_id' in kw:
                            print 'render node %s' % kw['node_id']
                            value = render_node(kw['node_id'], **kw)
                            print safe_dump(value, default_flow_style=False)
                        else:
                            #print safe_dump(rowify(result, [(x, None) for x in result[0].keys()]), default_flow_style=False)
                            print safe_dump([dict(zip(x.keys(), x.values())) for x in result], default_flow_style=False)

        elif selection == 'render_node':
            print globals()['render_node'].__doc__
            node_id = existing_node_input()

            value = render_value_for_node(node_id)
            print safe_dump(value, default_flow_style=False)

        elif selection == 'New collection':
            mode_new_collection()
        elif selection == 'Manage collection':
            mode_collection()
        elif selection == 'Add document for node':
            folder = current_app.config.get('DOCUMENT_FOLDER')
            if not folder:
                print "No DOCUMENT_FOLDER configured for the application."
            else:
                choices = map(os.path.basename,
                            glob(os.path.join(folder, '*'))
                            )
                choices.sort()
                if len(choices) == 0:
                    print "No files found in DOCUMENT_FOLDER."
                else:
                    filename = select(choices)
                    if filename:
                        defaultname = os.path.splitext(filename)[0]
                        nodename = raw_input("Enter name for node [{0}]: ".format(defaultname)) or defaultname
                        node = insert_node(name=nodename, value=filename)
                        print "Added document '%s' to node '%s' with id: %s" % (filename, nodename, node)
        elif selection == 'help':
            print "------"
            print __doc__
            print "------"
        else:
            print 'Done'
1310735
def selectlt(table, field, value, complement=False):
    """"""

    value = Comparable(value)
    return selectop(table, field, value, operator.lt, complement=complement)
734992
def selectgt(table, field, value, complement=False):
    """"""

    value = Comparable(value)
    return selectop(table, field, value, operator.gt, complement=complement)
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();
    }
815124
def selectin(table, field, value, complement=False):
    """"""

    return select(table, field, lambda v: v in value,
                  complement=complement)
663977
def operate_selected_rows(self, operator):
        '''
        '''
        model, tree_paths = self.selection.get_selected_rows()
        if not tree_paths:
            return
        fs_ids = []
        for tree_path in tree_paths:
            fs_ids.append(model[tree_path][FSID_COL])
        for fs_id in fs_ids:
            row = self.get_row_by_fsid(fs_id)
            if not row:
                return
            operator(row, scan=False)
        self.check_commit(force=True)
        self.scan_tasks(ignore_shutdown=True)
676509
private function select()
    {
        do {
            $mrc = curl_multi_exec($this->multi_handle, $active);
        } while ($mrc == CURLM_CALL_MULTI_PERFORM);

        while ($active && $mrc == CURLM_OK) {
            if (curl_multi_select($this->multi_handle) !== -1) {
                do {
                    $mrc = curl_multi_exec($this->multi_handle, $active);
                } while ($mrc == CURLM_CALL_MULTI_PERFORM);
            } else {
                return;
            }
        }

        while ($info = curl_multi_info_read($this->multi_handle)) {
            $ch = $info['handle'];
            $fd = (int)$ch;

            curl_multi_remove_handle($this->multi_handle, $ch);

            if (!isset($this->requests[$fd])) {
                return;
            }

            unset($this->requests[$fd]);
        }
    }
95485
def _run_select(self):
        
        return self._connection.select(
            self.to_sql(), self.get_bindings(), not self._use_write_connection
        )
668475
def select(cls, *args, **kwargs):
        """"""
        query = super(Model, cls).select(*args, **kwargs)
        query.database = cls._get_read_database()
        return query
438161
def select_from_table(fields, table, query):
    

    select_data = client.execute(f"SELECT {fields} FROM {table} {query}", with_column_types=True)

    keys = [i[0] for i in select_data[1]]

    result = []

    for i in range(len(select_data[0])):
        tmp = []

        for j in range(len(keys)):
            tmp.append(str(select_data[0][i][j]))

        result.append(dict(list(zip(keys, tmp))))

    # for i in range(len(select_data[0])):
    #     result.append(dict(list(zip(keys, select_data[0][i]))))

    return result
748584
def fetch(table, cols="*", where=(), group="", order=(), limit=(), **kwargs):
    """"""
    return select(table, cols, where, group, order, limit, **kwargs).fetchall()
713820
def select(query, data=None):
    
    connection = _State.connection()
    _State.new_transaction()
    if data is None:
        data = []

    result = connection.execute('select ' + query, data)

    rows = []
    for row in result:
        rows.append(dict(list(row.items())))

    return rows
406453
def selections(self):
        ""
        for key, value in self.pairs:
            if '__' in key:
                column, lookup = key.rsplit('__', 1)
            else:
                column = key
                lookup = 'exact'
            yield column, lookup, value
470788
def select(cls, symbol, start_date, end_date):
        """"""
        instance = cls(symbol, start_date, end_date)

        return instance.data
697089
def _select_limit_statement(table, cols='*', offset=0, limit=MAX_ROWS_PER_QUERY):
        """"""
        return 'SELECT {0} FROM {1} LIMIT {2}, {3}'.format(join_cols(cols), wrap(table), offset, limit)
1241697
def selectop(table, field, value, op, complement=False):
    """"""

    return select(table, field, lambda v: op(v, value),
                  complement=complement)
224853
function where(column, operator, value) {

    // Support "where true || where false"
    if (column === false || column === true) {
      return this.where(1, '=', column ? 1 : 0);
    }

    // Check if the column is a function, in which case it's
    // a where statement wrapped in parens.
    if (typeof column === 'function') {
      return this.whereWrapped(column);
    }

    // Allow a raw statement to be passed along to the query.
    if (column instanceof Raw && arguments.length === 1) {
      return this.whereRaw(column);
    }

    // Allows `where({id: 2})` syntax.
    if (typeof column === 'object' && !(column instanceof Raw)) {
      return this._objectWhere(column);
    }

    // Enable the where('key', value) syntax, only when there
    // are explicitly two arguments passed, so it's not possible to
    // do where('key', '!=') and have that turn into where key != null
    if (arguments.length === 2) {
      value = operator;
      operator = '=';

      // If the value is null, and it's a two argument query,
      // we assume we're going for a `whereNull`.
      if (value === null) {
        return this.whereNull(column);
      }
    }

    // lower case the operator for comparison purposes
    var checkOperator = ('' + operator).toLowerCase().trim();

    // If there are 3 arguments, check whether 'in' is one of them.
    if (arguments.length === 3) {
      if (checkOperator === 'in' || checkOperator === 'not in') {
        return this._not(checkOperator === 'not in').whereIn(arguments[0], arguments[2]);
      }
      if (checkOperator === 'between' || checkOperator === 'not between') {
        return this._not(checkOperator === 'not between').whereBetween(arguments[0], arguments[2]);
      }
    }

    // If the value is still null, check whether they're meaning
    // where value is null
    if (value === null) {

      // Check for .where(key, 'is', null) or .where(key, 'is not', 'null');
      if (checkOperator === 'is' || checkOperator === 'is not') {
        return this._not(checkOperator === 'is not').whereNull(column);
      }
    }

    // Push onto the where statement stack.
    this._statements.push({
      grouping: 'where',
      type: 'whereBasic',
      column: column,
      operator: operator,
      value: value,
      not: this._not(),
      bool: this._bool()
    });
    return this;
  }