Generate Python Class and SQLAlchemy code from XSD to store XML on Postgres -


i have complex xsd schemas work with. complex mean each of these xsd correspont 20 classes / tables in database, each table having approximately 40 fields. , have 18 different xsd program.

what i'm trying achieve is: xml file defined xsd , save data in postgresql database using sqlalchemy. need crud application persist xml file in database following model of xsd schema, , able retrieve object database , create xml file.

i want avoid having manually create python classes, sqlalchemy table definitions, crud code. monumental job, subject lot of small mistakes, given complexity of xsd files.

i can generate python classes xsd in many ways generateds, pyxb, etc... need save objects in database. i'm open suggestions, if suggestion conceptually different i'm describing.

thank much

you can use generateds create django models xsd. using gends_run_gen_django script, located under django directory in generateds source. here documentation on functionality. relevant quote:

here overview of process:

step 1. generate bindings -- run generateds.py. step 2. extract simpletype definitions schema -- run gends_extract_simple_types.py. step 3. generate models.py , forms.py -- run gends_generate_django.py. 

the script gends_run_gen_django.py performs these 3 steps.

i believe django should give of functionality of sqlalchemy. however, if decide use sqlalchemy instead generateds' django functionality might model on base similar sqlalchemy solution.


Comments