New Database Method: res_initializer()

While working on the database dump (putting all of Kelle’s data into the Python database), I wrote a new method to take care of 2 issues with the database. In it’s old state, we needed (and wanted) to have the resolution level of the structures (i.e. high, med, low, phot) initialized as empty dictionaries if no data exists. This was not the case, however. As a result, the dateList() method was no longer working, since it required this to be true. Also, having this level initialized makes the database dump (and any future dumps) easier. And so, this new method was born.

Remember, a method is a function attached to an object. In this case, the method is attached to our Python database. If you named the database bdnyc, then you can call the res_initializer() method with the command:
>>> bdnyc.res_initializer()              # No inputs are needed.

It’s simple–the method loops through all existing targets and adds these empty dictionaries if necessary. I also changed the addTarget method so that when you add a new target to the database, it will automatically run this method for you, unless you explicitly set init=False (if you’re adding multiple targets to the database, you can just wait until you put all of them in before running the initializer method).

If you are worried that I changed how you input new data into the database, don’t be: you can still follow Vivienne’s instructions on how to add data to the database, no changes necessary.

Leave a Reply

Your email address will not be published. Required fields are marked *