Discussion:
[ZODB-Dev] Iterate through all objects from ZODB
Carlos Sanchez
2014-09-23 03:12:09 UTC
Permalink
Hi,

I was wondering if there is an official API and/or a way to iterate through
all objects in a ZODB database. I found an implementation at
https://mail.zope.org/pipermail/zodb-dev/2002-October/003483.html, but I
was wondering if there are more recent solutions.

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

Thanks a lot

Carlos
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.zope.org/pipermail/zodb-dev/attachments/20140922/59fef6a8/attachment.html>
Andreas Jung
2014-09-23 04:27:15 UTC
Permalink
Post by Carlos Sanchez
Hi,
I was wondering if there is an official API and/or a way to iterate
through all objects in a ZODB database. I found an implementation at
https://mail.zope.org/pipermail/zodb-dev/2002-October/003483.html,
but I was wondering if there are more recent solutions.
We are using RelStorage (MySQL) and ZEO (4 Dev)
I doubt that there is such an API since every object can theoretically
implement its own storage and traversal strategy. In particular every
class can store data in subobjects or attributes that are not directly
available through an API. Zope-ish applications use a dict approach but
even this won't give you all and everything out of the box.

- -aj
Jim Fulton
2014-09-23 13:06:17 UTC
Permalink
On Mon, Sep 22, 2014 at 11:12 PM, Carlos Sanchez
Post by Carlos Sanchez
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.

...
Post by Carlos Sanchez
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
Loading...