Skip to content

Added ImportIndex annotation and support for updating DB instead of just inserting#10

Open
jp31415926 wants to merge 2 commits intojdewit:masterfrom
jp31415926:master
Open

Added ImportIndex annotation and support for updating DB instead of just inserting#10
jp31415926 wants to merge 2 commits intojdewit:masterfrom
jp31415926:master

Conversation

@jp31415926
Copy link

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.

@jdewit
Copy link
Owner

jdewit commented Jan 5, 2013

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.

@jp31415926
Copy link
Author

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 notifications@github.com 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:
#10 (comment)

@jp31415926
Copy link
Author

Let me just add that if the user does not annotate any fields as ImportIndex then the import works exactly as it did before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants