[ZODB-Dev] Iterate through all objects from ZODB

Jim Fulton jim at zope.com
Tue Sep 23 15:06:17 CEST 2014


On Mon, Sep 22, 2014 at 11:12 PM, Carlos Sanchez
<carlos.sanchez at nextthought.com> wrote:
> Hi,
>
> I was wondering if there is an official API and/or a way to iterate through
> all objects in a ZODB database.

In general, official interfaces are found in ZODB.interfaces.

IStorageCurrentRecordIteration lets you iterate over meta data about
objects in the database, including oid, tid and pickle. Both
FileStorage and ZEO implement this interface.

You can pass the oid to a connection's get method to get the object.
Iterating over the entire database requires some care to avoid
exceeding RAM.  After dealing with each object, you'll probably want
to call cacheGC on the connection to free unneeded memory.

...

> We are using RelStorage (MySQL) and ZEO (4 Dev)

I don't know if RelStorage implements IStorageCurrentRecordIteration.

Jim

-- 
Jim Fulton
http://www.linkedin.com/in/jimfulton


More information about the ZODB-Dev mailing list