XML to SQL or XML into Tables SomeHow
Thomas Weholt
thomas at cintra.no
Thu May 25 07:11:32 EDT 2000
Hi,
I want to submit a special formattet xml, nothing more than xml based
on a specified DTD, to a module/script that "transforms" the xml data
to a valid SQL insert-statement.
Ex.
<xml-data>
<database name="test">
<table name ="person">
<row>
<field field_name="name" value="thomas">
<field field_name="sex" value="male">
</row>
<row>
<field field_name="name" value="bill">
<field field_name="sex" value="male">
</row>
<row>
<field field_name="name" value="jane">
<field field_name="sex" value="female">
</row>
</table>
</database>
</xml-data>
I want an output like :
# SQL-statements
use test;
insert into person
(name, sex)
values
("thomas", "male");
insert into person
(name, sex)
values
("bill", "male");
insert into person
(name, sex)
values
("jane", "female");
##################
Perhaps the entries must have a specified type like
<field field_name="name" value="thomas" field_type="string"> etc.
For simple insertion statements this shouldn`t that hard to do, but
I`m having a hard time locating the stuff to do it.
I`ve looked at RAX, SAX, Pyxie etc. If somebody could give me a hint
on how to "transform" the example above I`d be happy to try and make a
more generic module out of it. I just need some help to get started.
Thomas
More information about the Python-list
mailing list