Hi, I have a requirement to constantly update data in my database tables (after the final schema has been designed) based on some external data source. I have written scripts to auto populate them (create/modify/ delete entries). I have been using a crude method for database interactions and I am presently in the process of standardizing it. Can you please help with some ideas?
This is one of the scenario I get list of current users from an external source, add new users, modify few attributes of current users (if changed), remove/deactivate those entries who are not present in source. I do a similar activity for 8 more tables. Current Procedure I follow - loop over all entries in the source - verify if the entry is present in database with all its attributes same as in source - update and create entries as required from above result - In parallel get a list of all entries which are in database and not in source remove them. I use django ORM. I have hard coded Model classes names with their arguments in the populating scripts which does seem bad. Standardization As part of standardizing, I have decided to set up a uniform database interactions (starting with insertions) for any model with any number of arguments where I should not hardcode model name and arguments in the script. One simple way of doing this would be as follows (though not it does not work for deleting the entries) - Write scripts to build dictionaries in the standard format which can then be deserialzed using serializers.deserialize. - While saving the deserialized objects a new entry will be created if the entry does not exist. - using natural keys is helpful for updating entries (without querying for pk value) - I am still exploring about deleting stale entries in database Can some one quickly help me with better ideas or pointers for my purpose? Thanks -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.