Exemple #1
0
 def itervalues(self):
     """
     Iterator over records in the database
     """
     for index in xrange(1, self.__len__() + 1):
         yield screedRecord._buildRecord(self.fields, self._db, index,
                                         DBConstants._PRIMARY_KEY)
Exemple #2
0
 def itervalues(self):
     """
     Iterator over records in the database
     """
     for index in xrange(1, self.__len__() + 1):
         yield screedRecord._buildRecord(self.fields, self._db,
                                         index,
                                         DBConstants._PRIMARY_KEY)
Exemple #3
0
 def __getitem__(self, key):
     """
     Retrieves from database the record with the key 'key'
     """
     cursor = self._db.cursor()
     key = str(key)  # So lazy retrieval objectes are evaluated
     query = 'SELECT %s FROM %s WHERE %s=?' % (
         self._queryBy, DBConstants._DICT_TABLE, self._queryBy)
     res = cursor.execute(query, (key, ))
     if type(res.fetchone()) == types.NoneType:
         raise KeyError("Key %s not found" % key)
     return screedRecord._buildRecord(self.fields, self._db, key,
                                      self._queryBy)
Exemple #4
0
 def loadRecordByIndex(self, index):
     """
     Retrieves record from database at the given index
     """
     cursor = self._db.cursor()
     index = int(index) + 1  # Hack to make indexing start at 0
     query = 'SELECT %s FROM %s WHERE %s=?' % (DBConstants._PRIMARY_KEY,
                                               DBConstants._DICT_TABLE,
                                               DBConstants._PRIMARY_KEY)
     res = cursor.execute(query, (index, ))
     if type(res.fetchone()) == types.NoneType:
         raise KeyError("Index %d not found" % index)
     return screedRecord._buildRecord(self.fields, self._db, index,
                                      DBConstants._PRIMARY_KEY)
Exemple #5
0
 def loadRecordByIndex(self, index):
     """
     Retrieves record from database at the given index
     """
     cursor = self._db.cursor()
     index = int(index) + 1  # Hack to make indexing start at 0
     query = 'SELECT %s FROM %s WHERE %s=?' % (DBConstants._PRIMARY_KEY,
                                               DBConstants._DICT_TABLE,
                                               DBConstants._PRIMARY_KEY)
     res = cursor.execute(query, (index,))
     if isinstance(res.fetchone(), type(None)):
         raise KeyError("Index %d not found" % index)
     return screedRecord._buildRecord(self.fields, self._db,
                                      index,
                                      DBConstants._PRIMARY_KEY)
Exemple #6
0
 def __getitem__(self, key):
     """
     Retrieves from database the record with the key 'key'
     """
     cursor = self._db.cursor()
     key = str(key)  # So lazy retrieval objectes are evaluated
     query = 'SELECT %s FROM %s WHERE %s=?' % (self._queryBy,
                                               DBConstants._DICT_TABLE,
                                               self._queryBy)
     res = cursor.execute(query, (key,))
     if isinstance(res.fetchone(), type(None)):
         raise KeyError("Key %s not found" % key)
     return screedRecord._buildRecord(self.fields, self._db,
                                      key,
                                      self._queryBy)