XML question - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: General (https://python-forum.io/forum-1.html) +--- Forum: News and Discussions (https://python-forum.io/forum-31.html) +--- Thread: XML question (/thread-25071.html) |
XML question - DPaul - Mar-18-2020 Hi, I'm just being curious When i program with an xml database, i can e.g. add a new "record", and even add a new field to existing records in the database etc.(using elementTree) It strikes me that during those operations you never say something like "save" or "additem", or... Only a the very end one does a tree.write(...), and that (probably) overwrites the existing xml file. My question: you start by reading the existing xml (db = ET.parse('members.xml') and this keeps the whole thing in memory until the moment that you do tree.write? I can imagine issues when the computer crashes. So, is it best proctice to do multiple tree.write()s during operations? thx, Paul RE: XML question - buran - Mar-18-2020 what exactly xml database is? If you mean xml file, same apply for other file/formats that is processed in memory - i.e. it's up to you to assess cost/benefits - e.g. drag on performance of I/O operation on large file vs. risk of losing info. RE: XML question - DPaul - Mar-18-2020 OK, thx. Paul |