Drop an Oracle-Loaded XSD in Python

Posted by in Software

A loaded schema can be dropped if:

  • No other schema depends on it
  • No data using the schema is loaded

I think you may force unloading schemas even if there is data loaded but I haven’t tried that.

The code to drop a schema is:

You can use it if e.g. schema is updated or we don’t need it anymore.

The full code in Python is:

Several notes:

  • The order of removal is, of course, the reversed order of insertion. This way, complex XSDs are removed firse leaving basic dependencies at the end.
  • I’m using PL/SQL because it’s easier if all scripts are written in the same way. I could probably use simple SQL
  • I’m over-engineering the code a bit because I don’t want it to fail hard if a dependency was not loaded (it’s development code so e.g. the list of schemas can fail to load in the first place)

Note: Please refer to the previous article to see e.g. connection setup via cx_oracle

HTH,


A little experiment: If you find this post and ad below useful, please check the ad out :-)