Skip to content

Mapper for serializing XML ElementTree with SQLAlchemy

This morning I've been working out how to configure a SQLAlchemy mapper to enable me to store an XML blob to relational databases.  Storing the XML element is a bit of  hack right now; ultimately, I want to map all the relevant pieces of the XML to appropriate Python object attributes.  But until I figure that mapping out, I'm saving the XML so in theory I can avoid making yet another API call.

I think I may have found relevant examples to guide me.  SQLAlchemy comes with a set of examples:  see docs and code (v 0.6.1) — specifically, the examples for serializing XML.  The first approach (using PickleType) is a simple and expedient approach, a good enough one to start with.   I'll come back to study the other ones.

Post a Comment

You must be logged in to post a comment.