-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upserting capabilities added at creation #108
Open
LariDG
wants to merge
13
commits into
main
Choose a base branch
from
include-upsert-capability
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
samueljackson92
requested changes
Jan 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is good, but can we split this into two different commands: create and update.
- create: clears the database and then creates everything
- update: only attempts to insert (or update) the data.
I think this should just be added as a command line option to the script.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I have added a function that will upsert tables when making them in the create script. Instead of dropping the database if it exists each time the script now does an upsert (update or insert) using the on_conflict_do_update command from sqlalchemy. I have tested it by changing the data in the
\tests\mock_data\index\
folder, initially only including half the shots, and then including all to see if the tables change as expected.What I am not sure about is in line 215
shot_metadata = shot_metadata.replace(np.nan, None)
I have changed nan to None as I kept getting an error (psycopg2.errors.NumericValueOutOfRange: integer out of range
) that column values were wrong for the schema and looking online it seems that Postgres doesn't equate nan to None. I am not sure why this doesn't break the previous version though as the schema and data is identical so I am a bit suspicious of this line.