[Zope-DB] Exporting data to mysql

Sukhwinder Singh ssruprai@hotmail.com
Thu, 26 Jun 2003 01:03:16 +0530


    I have a web application which is written by some other person using
zope/zodb/python. Now client wants to write this application using
php/mysql. But existing data stored in zodb database has to be exported to
mysql database. Zodb uses fileStorage to store data. I have tried zope's xml
export but that doesn't make any sense to me.

    Now problem is I don't have much knowledge about zope. I have only basic
knowledge that everything is stored as an object. I also have some knowledge
of python. I have searched the web for any information about zodb but could
not find much. I have only 2-3 days so I cannot learn zope then zodb and
then python. My problems are:

    1. How do I identify which of these objects store data(tables) because
zope stores everything (images, dhtml files, folders etc) as objects so I
want only objects which store data(rows) and then how many of these tables
are there?

    2.How do I determine how many fields are there in each data object and
what are their names and data types.

    3. How do I extract data from these objects and then store that to some
intermediate format (csv) and then import it to mysql.

    So what I want to do is introspection.

    I don't know where to start.

    There are many sub-folders under this web applications. I know that I
have to use external methods and I have tried it like this:

        from ZODB import FileStorage, DB
          storage = FileStorage.FileStorage('data.fs')
          db = DB( storage )
          connection = db.open()
          root = connection.root() // up to this point it works.

    now when I try something like:

          students = root['students']

      error message is displayed that students not found.

      For this reason I want to determine in which objects data is stored so
that I can get its values.
      I also have to determine the name of the attributes (fields) used in
this objects so that I can create mysql table fields of the same name and
data type.

      If possible, please give me complete code which I can just copy and
paste in external method file. If that is no possible then provide some
other working example or explain the steps in detail as I don't have much
knowledge about zope and co.

      --Sukhwinder Singh