I am developing an API in Unix environment for virtual machines. I have to store some information in a table about virtual machines.Currently I am using python dictionary of virtual machine objects and storing the same in pickle. I would like to know about other best ways(if any) to store the data in command line API's. Any suggestion would be helpful.
Ways to store data for command line API
python;storage;database;data
For an application used by others you should probably not use pickle as it is not save to load pickle data from untrusted sources (alternatively you would have to make 100% sure the pickled data could not be changed on disc between writing and reading).If the data ever needs modifying by users, you should have a look at writing it out using YAML. A Python implementation is available via PyYAML, but an emitter with better readable output would be pyaml.Alternatives are JSON and with more work XML.All of these require you to do translation to and from internal types to the types supported by the storage format (dictionaries/maps, lists, primitive types (ints, strings, boolean)). YAML also support user defined types with the same security issues as pickled Python data, but at least allows some safe loading, something that pickle doesn't support. YAML, through the explicit user types has less problems loading data after changing your source layout (renaming modules, moving classes) as you can experience with pickle.