[CentralOH] Pickling data into a database

Neil Ludban nludban at osc.edu
Wed Sep 3 22:56:03 CEST 2008


On Wed, 03 Sep 2008 14:32:36 -0400
Mark Erbaugh <mark at microenh.com> wrote:
...
> One of the outputs of this application is a performance curve that needs
> to be saved. In the current application, I create a one to many child
> table that has the X and Y coordinates of the curve (one pair per row).
> I could easily Pickle a sequence of tuples.  There are usually only a
> dozen or fewer points on the curve (I think the worst case is about 40).
> 
> Is this a good approach?  What are the potential pitfalls?

The serialized data is also difficult to look at for debugging,
repr() and eval() are simpler if you only need to support Python.  
Look at JSON and YAML for support in other languages.

> One pitfall that just came to mind is that this limits the ability of
> non-Python applications to process the data.  Maybe an alternative would
> be to convert the data to XML instead of Pickling it?

Overkill.  Simple text file formats like .ini or .csv can do a lot,
and the Python standard library supports them both.


More information about the CentralOH mailing list