Using PostgreSQL XML functions will be more efficient here, check
http://stackoverflow.com/questions/4967117/create-xml-from-postgresql/10399117#10399117for
examples.

You can try to do this in Python (by creating SQL selects for every table
and then parsing each return row into XML), but for it to work correctly
you would basically have to recreate those functions, which will take more
effort than just learning how to use them. Choose right tool for the job :-)

Konrad

On 23 October 2013 15:47, Ismar Sehic <[email protected]> wrote:

> Hello all.i have a quite big task, but i have a feeling it could be easily
> solved using python.
> The thing is, i need to export the whole company DB(Postgresql) to an XML
> template provided by another company.
> the template looks like this(just a fragment) :
>
> ?xml version="1.0" encoding="utf-8"?>
> <PropertyDetailsRS>
>   <Hotel>
>     <AgencyId />
>     <AgencyCode />
>     <GiataCode />
>     <Name />
>     <Descriptions>
>       <Description Lang="DE">
>         <Common />
>         <ShortDescription />
>         <LongDescription />
>         <Miscellaneous />
>         <Location />
>         <Interieur />
>         <ImportantRemark />
>       </Description>
>     </Descriptions>
>     <Category />
>     <Country />
>     <Region />
>     <City />
>     <Zip />
>     <Address />
>     <AdditionalAddress />
>     <Telephone />
>     <Fax />
>     <Email />
>     <Url />
>     <DestinationAirports>
>       <IataCode Code="BKK" />
>     </DestinationAirports>
>   </Hotel>
>   <RoomList>
>     <RoomGroup Id="" Code="" SeaView="" EN="" DE="">
>       <RoomDescriptions>
>         <RoomDescription Lang="">
>           <Description />
>         </RoomDescription>
>       </RoomDescriptions>
>     </RoomGroup>
>   </RoomList>
>   <BoardList>
>     <Board Id="" Code="" EN="" DE="" />
>   </BoardList>
>   ...
>
>
>
> i've never done anything like that.i'm familiar with psycopg2 module,
> also, i'm familiar with xml parsing(ElementTree, lxml).
> is there some way to use the provided xml as a template, then parse all
> the data according to the template, what is the moyt pythonic way to do
> this?
>
> Thx.
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> _______________________________________________
> Tutor maillist  -  [email protected]
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
>
_______________________________________________
Tutor maillist  -  [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to