[ZODB-Dev] Moving ZODB data into a relational database

Chris McDonough chrism at plope.com
Tue Mar 8 11:53:13 EST 2005


On Tue, 2005-03-08 at 02:45, Ruchith Fernando wrote:
> Hi,
> 
> I'm new to Python and ZODB.

Welcome!  The "new to Python" bit might be a problem for what you'll
need to do, but I suspect you'll manage.

> I'm trying to transfer contents of a ZODB database (Data.fs from ZOPE)
> to a ralational database. Can someone please advice me as to how to
> browse through the objects in zodb and extract the properties and
> values of those objects? Is it possible at all? The Data.fs file that
> I'm dealing with is about 500MB :-(

It's possible.  But unlike most relational databases, ZODB doesn't have
a query language like SQL.  Instead, it uses Python as its query
language.  In practice, this means that in order to get custom reports
from the data stored within a ZODB database, you'll ultimately need to
write a little (or a lot) of Python.

Zope is an application that makes use of ZODB.  It stores objects in
ZODB that have particular APIs.  The most useful of these APIs for
getting reports is the ObjectManager API, which is documented in the
Zope Help System.  If you can get a hold of a "folderish" object within
your ZODB, like so:

ZOPE_SOFTWARE_HOME = '/place/where/zope/lives/lib/python'
sys.path.insert(0, ZOPE_SOFTWARE_HOME)
import Zope
Zope.configure('/place/where/zopeinstance/lives/etc/zope.conf')
app = Zope.app()
# app is now the "root" folder object and you can use methods
# of the ObjectManager API against it, e.g.
app.objectValues()

Then each object in the returned list of objects has its own API
(depending on what it is).  Most of the object APIs are documented
within the help system unless you're using third-party products.

The best reference is always the source.

If your Zope objects are simple "file-like" objects you may just want to
attach to Zope via WebDAV (see the Zope Book "External Tools" chapter at
http://www.plope.com/Books/2_7Edition/ExternalTools.stx) for more info
and copy them out to files, which might put you in a place where you're
more comfortable dealing with the data.

> Also do you know any freely available tool (Other than ZMI) that would
> help me view the contents of a ZODB database?

There are debugging tools that do this but they don't show the content
in any way that makes sense to someone who just wants to see "the
content".

HTH,

- C




More information about the ZODB-Dev mailing list