[Zope] Exporting zodb data (Urgent)
Sukhwinder Singh
ssruprai@hotmail.com
Fri, 27 Jun 2003 21:28:41 +0530
This is a multi-part message in MIME format.
------=_NextPart_000_0049_01C33CF3.14BC2560
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hello,
(I posted this question to zope-db@zope.org but no one replied so I =
am posting it here as it is urgent.)
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 =3D FileStorage.FileStorage('data.fs')
db =3D DB( storage )
connection =3D db.open()
root =3D connection.root() // up to this point it works.
now when I try something like:
students =3D 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.
=20
------=_NextPart_000_0049_01C33CF3.14BC2560
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2614.3500" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hello,<BR><BR> (I =
posted this=20
question to <A href=3D"mailto:zope-db@zope.org">zope-db@zope.org</A> but =
no one=20
replied so I am posting it here as it is urgent.)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I have a web application which is =
written by some=20
other person using<BR>zope/zodb/python. Now client wants to write this=20
application using<BR>php/mysql. But existing data stored in zodb =
database has to=20
be exported to<BR>mysql database. Zodb uses fileStorage to store data. I =
have=20
tried zope's xml<BR>export but that doesn't make any sense to=20
me.<BR><BR> Now problem is I don't have much knowledge =
about=20
zope. I have only basic<BR>knowledge that everything is stored as an =
object. I=20
also have some knowledge<BR>of python. I have searched the web for any=20
information about zodb but could<BR>not find much. I have only 2-3 days =
so I=20
cannot learn zope then zodb and<BR>then python. My problems=20
are:<BR><BR> 1. How do I identify which of these =
objects store=20
data(tables) because<BR>zope stores everything (images, dhtml files, =
folders=20
etc) as objects so I<BR>want only objects which store data(rows) and =
then how=20
many of these tables<BR>are there?<BR><BR> 2.How do I=20
determine how many fields are there in each data object and<BR>what are =
their=20
names and data types.<BR><BR> 3. How do I extract data =
from=20
these objects and then store that to some<BR>intermediate format (csv) =
and then=20
import it to mysql.<BR><BR> So what I want to do is=20
introspection.<BR><BR> I don't know where to=20
start.<BR><BR> There are many sub-folders under this =
web=20
applications. I know that I<BR>have to use external methods and I have =
tried it=20
like this:<BR><BR> from ZODB =
import=20
FileStorage, =
DB<BR> =20
storage =3D=20
FileStorage.FileStorage('data.fs')<BR>  =
; =20
db =3D DB( storage =
)<BR> =20
connection =3D =
db.open()<BR> =20
root =3D connection.root() // up to this point it =
works.<BR><BR> =20
now when I try something=20
like:<BR><BR> =
students =3D=20
root['students']<BR><BR> error message is=20
displayed that students not found.<BR><BR> =
For=20
this reason I want to determine in which objects data is stored =
so<BR>that I can=20
get its values.<BR> I also have to =
determine the=20
name of the attributes (fields) used in<BR>this objects so that I can =
create=20
mysql table fields of the same name and<BR>data=20
type.<BR><BR> If possible, please give me =
complete=20
code which I can just copy and<BR>paste in external method file. If that =
is no=20
possible then provide some<BR>other working example or explain the steps =
in=20
detail as I don't have much<BR>knowledge about zope and=20
co.<BR><BR> </FONT></DIV></BODY></HTML>
------=_NextPart_000_0049_01C33CF3.14BC2560--