从数据库里查询所有记录
        Args:
            table: 表名字 str
            limit: 限制数量
        return:
            成功： [dict] 保存的记录
            失败： -1 并打印返回报错信息
772948
def find_all(self, table, limit=10):
        '''
        
        '''
        sql = "select * from {} limit 0,{}".format(table, limit)
        res = self.query(sql)
        return res
874154
def _parse_throttle(self, tablename, throttle):
        
        amount = []
        desc = self.describe(tablename)
        throughputs = [desc.read_throughput, desc.write_throughput]
        for value, throughput in zip(throttle[1:], throughputs):
            if value == "*":
                amount.append(0)
            elif value[-1] == "%":
                amount.append(throughput * float(value[:-1]) / 100.0)
            else:
                amount.append(float(value))
        cap = Capacity(*amount)  # pylint: disable=E1120
        return RateLimit(total=cap, callback=self._on_throttle)
1327563
def enumerate_query_by_limit(q, limit=1000):
    
    for offset in count(0, limit):
        r = q.offset(offset).limit(limit).all()

        for row in r:
            yield row

        if len(r) < limit:
            break
1088643
def get_sql(self):
        
        sql = ''
        if self.limit and self.limit > 0:
            sql += 'LIMIT {0} '.format(self.limit)
        if self.offset and self.offset > 0:
            sql += 'OFFSET {0} '.format(self.offset)
        return sql
541639
def count(self, table):
        
        if self._operator is None and self._operands is None:
            return self._get_table_len(table)

        return np.count_nonzero(self.mask(table))
12322
def dos_from_table(table, header=None):
    
    start_row = 0
    if not table:
        return table
    if not header:
        header = table[0]
        start_row = 1
    header_list = header
    if header and isinstance(header, basestring):
        header_list = header.split('\t')
        if len(header_list) != len(table[0]):
            header_list = header.split(',')
        if len(header_list) != len(table[0]):
            header_list = header.split(' ')
    ans = {}
    for i, k in enumerate(header):
        ans[k] = [row[i] for row in table[start_row:]]
    return ans
146223
def list_documents(self, limit=None):
        
        limit_str = ''
        if limit:
            try:
                limit_str = 'LIMIT {}'.format(int(limit))
            except (TypeError, ValueError):
                pass

        query = ('SELECT identifier FROM identifier_index ' + limit_str)

        for row in self.backend.library.database.connection.execute(query).fetchall():
            yield row['identifier']
847411
def _build_table(self, info, order, max_col_len=40, only_changed=False):
        

        info_dict, bounds_dict = {}, {}
        (params, val_dict, changed) = info
        col_widths = dict((k,0) for k in order)

        for name, p in params.items():
            if only_changed and not (name in changed):
                continue

            constant = 'C' if p.constant else 'V'
            readonly = 'RO' if p.readonly else 'RW'
            allow_None = ' AN' if hasattr(p, 'allow_None') and p.allow_None else ''

            mode = '%s %s%s' % (constant, readonly, allow_None)
            info_dict[name] = {'name': name, 'type':p.__class__.__name__,
                               'mode':mode}

            if hasattr(p, 'bounds'):
                lbound, ubound = (None,None) if p.bounds is None else p.bounds

                mark_lbound, mark_ubound = False, False
                # Use soft_bounds when bounds not defined.
                if hasattr(p, 'get_soft_bounds'):
                    soft_lbound, soft_ubound = p.get_soft_bounds()
                    if lbound is None and soft_lbound is not None:
                        lbound = soft_lbound
                        mark_lbound = True
                    if ubound is None and soft_ubound is not None:
                        ubound = soft_ubound
                        mark_ubound = True

                if (lbound, ubound) != (None,None):
                    bounds_dict[name] = (mark_lbound, mark_ubound)
                    info_dict[name]['bounds'] = '(%s, %s)' % (lbound, ubound)

            value = repr(val_dict[name])
            if len(value) > (max_col_len - 3):
                value = value[:max_col_len-3] + '...'
            info_dict[name]['value'] = value

            for col in info_dict[name]:
                max_width = max([col_widths[col], len(info_dict[name][col])])
                col_widths[col] = max_width

        return self._tabulate(info_dict, col_widths, changed, order, bounds_dict)
239150
def getLimits(locations, current, sortResults=True, verbose=False):
    
    limit = {}
    for l in locations:
        a, b = current.common(l)
        if a is None:
            continue
        for name, value in b.items():
            f = a[name]
            if name not in limit:
                limit[name] = {}
                limit[name]['<'] = {}
                limit[name]['='] = {}
                limit[name]['>'] = {}
                if f > 0:
                    limit[name]['>'] = {0: [Location()]}
                elif f<0:
                    limit[name]['<'] = {0: [Location()]}
                else:
                    limit[name]['='] = {0: [Location()]}
            if current[name] < value - _EPSILON:
                if value not in limit[name]["<"]:
                    limit[name]["<"][value] = []
                limit[name]["<"][value].append(l)
            elif current[name] > value + _EPSILON:
                if value not in limit[name][">"]:
                    limit[name][">"][value] = []
                limit[name][">"][value].append(l)
            else:
                if value not in limit[name]["="]:
                    limit[name]["="][value] = []
                limit[name]["="][value].append(l)
    if not sortResults:
        return limit
    # now we have all the data, let's sort to the relevant values
    l = {}
    for name, lims in  limit.items():
        less = []
        more = []
        if lims[">"].keys():
            less = sorted(lims[">"].keys())
            lim_min = less[-1]
        else:
            lim_min = None
        if lims["<"].keys():
            more = sorted(lims["<"].keys())
            lim_max = more[0]
        else:
            lim_max = None
        if lim_min is None and lim_max is not None:
            # extrapolation < min
            if len(limit[name]['='])>0:
                l[name] = (None, list(limit[name]['='].keys())[0], None)
            elif len(more) > 1 and len(limit[name]['='])==0:
                # extrapolation
                l[name] = (None,  more[0], more[1])
        elif lim_min is not None and lim_max is None:
            # extrapolation < max
            if len(limit[name]['='])>0:
                # less > 0, M > 0, more = None
                # -> end of a limit
                l[name] = (None, limit[name]['='], None)
            elif len(less) > 1 and len(limit[name]['='])==0:
                # less > 0, M = None, more = None
                # extrapolation
                l[name] = (less[-2], less[-1], None)
        else:
            if len(limit[name]['=']) > 0:
                l[name] = (None, list(limit[name]['='].keys())[0], None)
            else:
                l[name] = (lim_min,  None, lim_max)
    return l
202636
def __get_table_limits():
    """"""

    table_counts = {
        'max_adjectives': None,
        'max_names': None,
        'max_nouns': None,
        'max_sentences': None,
        'max_faults': None,
        'max_verbs': None
    }

    cursor = CONN.cursor()

    cursor.execute('SELECT count(*) FROM suradjs')
    table_counts['max_adjectives'] = cursor.fetchone()
    table_counts['max_adjectives'] = table_counts['max_adjectives'][0]

    cursor.execute('SELECT count(*) FROM surnames')
    table_counts['max_names'] = cursor.fetchone()
    table_counts['max_names'] = table_counts['max_names'][0]

    cursor.execute('SELECT count(*) FROM surnouns')
    table_counts['max_nouns'] = cursor.fetchone()
    table_counts['max_nouns'] = table_counts['max_nouns'][0]

    cursor.execute('SELECT count(*) FROM sursentences')
    table_counts['max_sen'] = cursor.fetchone()
    table_counts['max_sen'] = table_counts['max_sen'][0]

    cursor.execute('SELECT count(*) FROM surfaults')
    table_counts['max_fau'] = cursor.fetchone()
    table_counts['max_fau'] = table_counts['max_fau'][0]

    cursor.execute('SELECT count(*) FROM surverbs')
    table_counts['max_verb'] = cursor.fetchone()
    table_counts['max_verb'] = table_counts['max_verb'][0]

    return table_counts
40584
def clean_limit(self):
        ""
        limit = self.cleaned_data.get('limit', None)
        if (settings.SELECTABLE_MAX_LIMIT is not None and
            (not limit or limit > settings.SELECTABLE_MAX_LIMIT)):
            limit = settings.SELECTABLE_MAX_LIMIT
        return limit
1253005
def limit(self, num):
        
        jdf = self._jdf.limit(num)
        return DataFrame(jdf, self.sql_ctx)
215563
def get_limits(self):
        
        if self.limits != {}:
            return self.limits
        limits = {}
        limits['Groups'] = AwsLimit(
            'Groups',
            self,
            300,
            self.warning_threshold,
            self.critical_threshold,
            limit_type='AWS::IAM::Group',
        )
        limits['Users'] = AwsLimit(
            'Users',
            self,
            5000,
            self.warning_threshold,
            self.critical_threshold,
            limit_type='AWS::IAM::User',
        )
        limits['Roles'] = AwsLimit(
            'Roles',
            self,
            1000,
            self.warning_threshold,
            self.critical_threshold,
            limit_type='AWS::IAM::Role',
        )
        limits['Instance profiles'] = AwsLimit(
            'Instance profiles',
            self,
            1000,
            self.warning_threshold,
            self.critical_threshold,
            limit_type='AWS::IAM::InstanceProfile',
        )
        limits['Server certificates'] = AwsLimit(
            'Server certificates',
            self,
            20,
            self.warning_threshold,
            self.critical_threshold,
            limit_type='AWS::IAM::ServerCertificate',
        )
        limits['Policies'] = AwsLimit(
            'Policies',
            self,
            1500,
            self.warning_threshold,
            self.critical_threshold,
            limit_type='AWS::IAM::Policy',
        )
        limits['Policy Versions In Use'] = AwsLimit(
            'Policy Versions In Use',
            self,
            10000,
            self.warning_threshold,
            self.critical_threshold,
            limit_type='AWS::IAM::ServerCertificate',
        )
        self.limits = limits
        return limits
19779
def table_info(table_name):
    
    table = orca.get_table(table_name).to_frame()
    buf = StringIO()
    table.info(verbose=True, buf=buf)
    info = buf.getvalue()
    return info, 200, {'Content-Type': 'text/plain'}
474016
def results(self):
    
    self.wait()
    if self.failed:
      raise Exception('Query failed: %s' % str(self.errors))
    return self._table
123832
def get_rate_limits(self):
        
        resp, body = self.method_get("/limits")
        rate_limits = body.get("limits", {}).get("rate")
        ret = []
        for rate_limit in rate_limits:
            limits = rate_limit["limit"]
            uri_limits = {"uri": rate_limit["uri"],
                    "limits": limits}
            ret.append(uri_limits)
        return ret
337390
def readTable(self, tableName):
        
        lock_and_call(
            lambda: self._impl.readTable(tableName),
            self._lock
        )