Skip to content
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

GRAMEX-97 ⁃ ENH: Update multiple rows in files and DBs with data.update #456

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

jaidevd
Copy link
Member

@jaidevd jaidevd commented Sep 28, 2021

Closes #312

┆Issue is synchronized with this Jira Bug

@sync-by-unito sync-by-unito bot changed the title ENH: Update multiple rows in files and DBs with data.update GRAMEX-97 ⁃ ENH: Update multiple rows in files and DBs with data.update Sep 28, 2021

names = ['Humphrey Bogart', 'James Stewart', 'Audrey Hepburn']
categories = ['Stars', 'Thespians', 'Heartthrobs']
ratings = [1, 0.99, 1.11]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a test case where

  • ratings has only 2 values [1, 0.99] and the third is missing. Audrey's rating should not get updated, but her categories should be.
  • names has only 2 values -- in which case, the 3rd category and rating are ignored

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sanand0 This works for files, but for sqlalchemy, to deal with uneven args, we might have to do column-wise update queries. Is this acceptable?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jaidevd -- yes, column-wise update queries are fine. I don't anticipate this to be used often and we can optimize later

df = gramex.data.filter(temp_db, args={'name': names}, table='actors')
self.assertEqual(df['category'].tolist(), categories)
self.assertEqual(df['rating'].tolist(), ratings)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add test cases for MySQL, PostgreSQL.

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.

Cannot update multiple rows with gramex.data.update
2 participants