Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have some very complex XSD schemas to work with. By complex I mean that each of these XSD would correspont to about 20 classes / tables in a database, with each table having approximately 40 fields. And I have 18 different XSD like that to program.

What I'm trying to achieve is: Get a XML file defined by the XSD and save all the data in a PostgreSQL database using SQLAlchemy. Basically I need a CRUD application that will persist a XML file in the database following the model of the XSD schema, and also be able to retrieve an object from the database and create a XML file.

I want to avoid having to manually create the python classes, the sqlalchemy table definitions, the CRUD code. This would be a monumental job, subject to a lot of small mistakes, given the complexity of the XSD files.

I can generate python classes from XSD in many ways like GenerateDS, PyXB, etc... I need to save those objects in the database. I'm open to any suggestions, even if the suggestion is conceptually different that what I'm describing.

Thank you very much

share|improve this question

1 Answer 1

up vote 2 down vote accepted

You can use generateDS to create django models from your XSD. You do this using the gends_run_gen_django script, which is located under the django directory in the generateDS source. Here is some documentation on that functionality. Relevant quote:

Here is an overview of the process:

Step 1. Generate bindings -- Run generateDS.py.
Step 2. Extract simpleType definitions from schema -- Run
gends_extract_simple_types.py.
Step 3. Generate models.py and forms.py -- Run gends_generate_django.py.

The script gends_run_gen_django.py performs these three steps.

I believe django should give you most of the functionality of sqlalchemy. However, if you decide to use sqlalchemy instead then generateDS' django functionality might be a good model on which to base a similar sqlalchemy solution.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.