Convert XML to SQL

Johann Spies johann.spies at gmail.com
Wed Jan 26 04:07:33 EST 2011


I an not a Python newbie but working with xml is new to me.

I get data through a soap connection, using suds, and want to convert that
to objects which I can use to populate a rather complex database.

I have been able to parse the xml using

tree = etree.iterparse(infile,events=("start","end")) but it seems like a
lot of work to get that to sql-objects.

I have seen references to lxml.objectify and have created a object
containing the contents of a whole file using

tree = objectify.parse(fileobject)

That object contains for example the data of 605 records and I do not know
how to use it. I could not figure out from the lxml.objectify documentation
how to do it.

In the end I want to use data from about 54 fields of each records.  I would
like to have a list of dictionaries as a result of the parsing.  From there
it should not be too difficult to create sql.

I have seen some references to BeautifulSoap but I am not sure which is the
best way to go.

So:

Is there a better tool than lxml to do this?
Is it possible to do it just using suds? The suds documentation did not
really help me to do this with complex data.
Are there good tutorials for the xml->sql process?

Regards
Johann
-- 
 May grace and peace be yours in abundance through the full knowledge of God
and of Jesus our Lord!  His divine power has given us everything we need for
life and godliness through the full knowledge of the one who called us by
his own glory and excellence.
                                                    2 Pet. 1:2b,3a
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110126/8b076c64/attachment.html>


More information about the Python-list mailing list