AvroCsvBundle
AvroCsvBundle copied to clipboard
Added ImportIndex annotation and support for updating DB instead of just inserting
I needed a way to import changes to existing records instead of deleting them by hand and then importing. This code does that by annotating "ImportIndex" fields that are used to find an existing and update it (if it exists).
Also removed unneeded table in the import template and other minor changes.
Hope you can use it.
Updating your db with a csv?? I don't think this is a very good idea.
The first import would work, but how does the second import account for any rows added by the application? You would have to manually map the id's or generate unique id's instead of having them increment.
Look at the code. It loads a record that matches the index-annotated fields. If it finds it, it updates the rest of the fields with the new values, but keeps the same id. If it doesn't, it creates a new record (entity).
This is something we use all the time to upload game schedules. Some mass changes are much easier with excel, so we export, change, and re-import the data.
On 1/5/13, jdewit [email protected] wrote:
Updating your db with a csv?? I don't think this is a very good idea.
The first import would work, but how does the second import account for any rows added by the application? You would have to manually map the id's or generate unique id's instead of having them increment.
Reply to this email directly or view it on GitHub: https://github.com/jdewit/AvroCsvBundle/pull/10#issuecomment-11915399
Let me just add that if the user does not annotate any fields as ImportIndex then the import works exactly as it did before.