Skip to content
This repository was archived by the owner on Jan 8, 2026. It is now read-only.

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

Open
jaidevd wants to merge 3 commits into
masterfrom
jd-update-multi
Open

GRAMEX-97 ⁃ ENH: Update multiple rows in files and DBs with data.update#456
jaidevd wants to merge 3 commits into
masterfrom
jd-update-multi

Conversation

@jaidevd

@jaidevd jaidevd commented Sep 28, 2021

Copy link
Copy Markdown
Contributor

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
Comment thread testlib/test_data.py

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

Copy link
Copy Markdown
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
Copy Markdown
Contributor 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
Copy Markdown
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

Comment thread testlib/test_data.py
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
Copy Markdown
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 subscribe to this conversation on GitHub. Already have an account? Sign in.

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