iterate keys in a db
777315
function iterateKeys() {
      var obj = getKeyObject(db, j);
      if(obj === null) return onKeysComplete();
      encoder.write(obj, function onWrite() {
        j++;
        setImmediate(iterateKeys);
      });
    }
1089036
def _batch_key(self, query):
    '''
    
    '''
    return ''.join( ['%s%s'%(k,v) for k,v in sorted(query.items())] )
611530
def _iter_keys_as_str(key):
    
    for i in range(winreg.QueryInfoKey(key)[0]):
        yield winreg.EnumKey(key, i)
736987
def keys():
    """"""
    for admin in current_app.config['ADMIN_USERS']:
        try:
            db.get_db()  # init db on global app context
            keys = ApiKey.find_by_user(admin)
        except Exception as e:
            click.echo('ERROR: {}'.format(e))
        else:
            for key in keys:
                click.echo('{:40} {}'.format(key.key, key.user))
1162536
def build_for_each(self, db, safe_mode=False, extra=None):
        """"""
        result = dict()
        for var, query in iteritems(self.for_each):
            result[var] = db.query(
                query,
                additional_locals=extra,
                safe_mode=safe_mode
            )
        return result
1173801
def iterkeys(self):
        ""
        return chain(self._pb.StringMap.keys(),
                     self._pb.IntMap.keys(),
                     self._pb.FloatMap.keys(),
                     self._pb.BoolMap.keys())
344261
def _dict_set(self, key, val):
        '''
        
        '''
        if key != None and self.stringify_keys:
            key = str(key)
        db = self._keyed_db[self.split_func(key)]
        db._dict_set(key, val)
1272465
def iterateFilteredRecords( dbid, fieldNames, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", options = nil )
      fields = []
      regexp = {}
      fieldNames.each{|field|
         if field.is_a?(Hash)
            fields << field.keys[0]
            regexp[field.keys[0]] = field.values[0]
         elsif field.is_a?(String)
            fields << field
         end
      }
      regexp = nil if regexp.length == 0
      iterateRecords(dbid,fields,query,qid,qname,clist,slist,fmt,options){|record|
         if regexp
            match = true
            fields.each{|field|
               if regexp[field] 
                  unless record[field] and record[field].match(regexp[field])
                     match = false 
                     break
                  end
               end
            }
            yield record if match
         else
            yield record
         end
      }
   end
1232636
def gen_multi_key(self, values, db='default'):
        """"""
        db = settings.DB_CACHE_KEYS[db]
        if db and len(db) > 100:
            db = db[0:68] + self.gen_key(db[68:])
        return '%s_%s_multi_%s' % (self.prefix, db, self.gen_key(*values))
371266
def keys_to_values(self, keys):
        ""
        return dict((k, v) for k, v in self.data.items() if k in keys)
1043651
async def executemany(self, sql: str, parameters: Iterable[Iterable[Any]]) -> None:
        """"""
        await self._execute(self._cursor.executemany, sql, parameters)
1068492
def items(self):
        """"""
        keycol = self._keycol
        for row in self.__iter__():
            yield (row[keycol], dict(row))
1011217
def keys(self, prefix=None):
        """"""
        query = Setting.query
        if prefix:
            query = query.filter(Setting.key.startswith(prefix))

        # don't use iteritems: 'value' require little processing whereas we only
        # want 'key'
        return [i[0] for i in query.yield_per(1000).values(Setting.key)]
48842
def iteritems(self, prefix=None):
        """"""
        query = Setting.query
        if prefix:
            query = query.filter(Setting.key.startswith(prefix))

        for s in query.yield_per(1000):
            yield (s.key, s.value)
455043
def keys(pattern = SCAN_PATTERN, count = DEFAULT_COUNT)
      return redis(&:keys) if pattern.nil?

      redis { |conn| conn.scan_each(match: prefix(pattern), count: count).to_a }
    end
993836
def insert_keys(self, keys):
        """"""
        start = 0
        bulk_insert = self.bulk_insert
        keys_len = len(keys)
        query = 'INSERT IGNORE INTO gauged_keys (namespace, `key`) VALUES '
        execute = self.cursor.execute
        while start < keys_len:
            rows = keys[start:start+bulk_insert]
            params = [param for params in rows for param in params]
            insert = '(%s,%s),' * (len(rows) - 1) + '(%s,%s)'
            execute(query + insert, params)
            start += bulk_insert
896755
def list(self):
        """"""
        return [x["_id"] for x in self._db.system.js.find(projection=["_id"])]