Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
XML question
#1
Hi,

I'm just being curious Cool
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
Reply
#2
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.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
OK, thx.

Paul
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020