XML to SQL or XML into Tables SomeHow

Thomas Weholt thomas at cintra.no
Fri May 26 09:02:32 EDT 2000


Eh .. yes, I`m looking into that right now. Realized that would
probably much more generic and easier to change than python-code.

I`ll post any module or whatever comes out of my efforts. 

Thanks to Robert Roy for making a code example, like I asked for. 

Thomas

On Thu, 25 May 2000 22:45:23 +0100, "Phil" <pharris at crosswinds.net>
wrote:

>Couldn't you use xslt to do the transformation, since that is its purpose
>
>
>"Thomas Weholt" <thomas at cintra.no> wrote in message
>news:392e080f.1310806219 at news.online.no...
>> 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