-
-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Adding overwrite or ignore behavior for row conflicts. #46232
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
Closed
Closed
Changes from 132 commits
Commits
Show all changes
136 commits
Select commit
Hold shift + click to select a range
848becc
updated .gitignore to ignore .python-version file
cvonsteg d9f7c23
skeleton framework
cvonsteg f0726b3
update docstring and add TODO
cvonsteg c742f47
scratch functions added
cvonsteg d2a0c2d
generator comment
cvonsteg 686930c
Squashed 'vendor/github.com/V0RT3X4/python_utils/' content from commi…
cvonsteg 1f47d45
Add "python_utils" from "git@github.com:V0RT3X4/python_utils.git@master"
cvonsteg 881a934
Add "python_utils" from "git@github.com:V0RT3X4/python_utils.git@master"
cvonsteg c95de1d
update scratch
cvonsteg 0082347
update scratch
cvonsteg 2d85c70
starting to modify sql.py adding workflow for insert method, and scra…
cvonsteg 0f32cd0
starting to modify sql.py adding workflow for insert method, and scra…
cvonsteg dc70c40
sql.py - methods to get pkey columns, pkey iterator, and almost finis…
cvonsteg a7b8e8e
sql.py - methods to get pkey columns, pkey iterator, and almost finis…
cvonsteg 1d936ef
changed upsert to if_exists option, beginning implementation
cvonsteg 9db2aaa
changed upsert to if_exists option, beginning implementation
cvonsteg 57a246d
all workflow present - now to debugging
cvonsteg c290a78
all workflow present - now to debugging
cvonsteg 35e0fc4
tidy up repo
cvonsteg 6bcd6c2
tidy up repo
cvonsteg 00e6319
Squashed 'vendor/github.com/V0RT3X4/python_utils/' content from commi…
cvonsteg 8d654ca
Add "python_utils" from "git@github.com:V0RT3X4/python_utils.git@master"
cvonsteg 966a95c
Add "python_utils" from "git@github.com:V0RT3X4/python_utils.git@master"
cvonsteg b214a68
added df argument to stop original df from getting deleted by upsert_…
cvonsteg 41938cd
added df argument to stop original df from getting deleted by upsert_…
cvonsteg 78f8e86
tidying up sql.py code and adding helpers to sql_scratch.py
cvonsteg 025b0ef
tidying up sql.py code and adding helpers to sql_scratch.py
cvonsteg bbcf92b
made upsert_delete mask index agnostic
cvonsteg 73fea73
made upsert_delete mask index agnostic
cvonsteg d8b7686
updated docuemntation for to_sql method
cvonsteg 75e16ff
updated docuemntation for to_sql method
cvonsteg 0dfe913
Added basic tests - need to figure out why postgres tests aren't working
cvonsteg 779818a
Added basic tests - need to figure out why postgres tests aren't working
cvonsteg 3fafc95
updated docstrings and added desription to
cvonsteg d79b970
updated docstrings and added desription to
cvonsteg c38f900
remove vendor
cvonsteg 0636332
Merge branch 'sql-upsert' of github.com:V0RT3X4/pandas into sql-upsert
cvonsteg a15fc2f
clean up for PR
cvonsteg 6c44506
wrapped whole insert workflow in transaction to avoid postgres freezing
cvonsteg e409bda
ENH: black file
cvonsteg d35e145
pep8 formatting
cvonsteg 8a57126
black formatting sql.py
cvonsteg 3c308d3
Merge branch 'master' into sql-upsert
cvonsteg d4764dc
Merge branch 'sql-upsert' of github.com:V0RT3X4/pandas into sql-upsert
cvonsteg 4396aa3
Merge branch 'master' into sql-upsert
cvonsteg 2b1c797
reformatted tests, added requested changes, and updated generic docst…
cvonsteg b23f528
reformatted tests, added requested changes, and updated generic docst…
cvonsteg 899da90
line-separated docstring in generc and removed unwatned pattern from …
cvonsteg 8ebc256
postgresql type-o and type-checking in sql tests
cvonsteg baad9e3
reformatting tests
cvonsteg 79ef9c0
remove quotations from postgres queries
cvonsteg d0eb251
postgres formatting
cvonsteg b838ef5
Merge branch 'master' into sql-upsert
cvonsteg 17a1d42
Merge remote-tracking branch 'upstream/master' into sql-upsert
cvonsteg a25c2f3
Merge remote-tracking branch 'upstream/master' into sql-upsert
cvonsteg f56b53f
Merge remote-tracking branch 'upstream/master' into sql-upsert
cvonsteg 247bec0
Merge remote-tracking branch 'upstream/master' into sql-upsert
cvonsteg 51a74a2
Merge remote-tracking branch 'upstream/master' into sql-upsert
cvonsteg 91c750b
Merge remote-tracking branch 'upstream/master' into sql-upsert
cvonsteg f940b42
Merge remote-tracking branch 'upstream/master' into sql-upsert
cvonsteg 6dedb71
Merge remote-tracking branch 'upstream/master' into sql-upsert
cvonsteg e3809a1
Merge remote-tracking branch 'upstream/master' into sql-upsert
cvonsteg 6d692cd
merging master
cvonsteg efd2382
removed temp=self.frame in _get_index_formatted_dataframe
cvonsteg c3a6a95
Merge remote-tracking branch 'upstream/master' into sql-upsert
cvonsteg a0ce842
Merge remote-tracking branch 'upstream/master' into sql-upsert
cvonsteg 07bc8ca
Merge remote-tracking branch 'upstream/master' into sql-upsert
cvonsteg 4822ce0
Commenting out tests to confirm that stalled builds are caused by ups…
cvonsteg 0fba1b6
re-enabling to_sql_upsert_keep test
cvonsteg c230d16
re-enabling to_upsert_ignore, whilst disabling to_upsert_keep
cvonsteg 9a7ef9c
Merge remote-tracking branch 'upstream/master' into sql-upsert
cvonsteg 2a078f6
Merge remote-tracking branch 'upstream/master' into sql-upsert
cvonsteg c3c6ed1
clean up flake8 version, re-activate test
cvonsteg 79becdc
remove SQLAlchemyConn tests to confirm hypothesis
cvonsteg 3b6ca76
relaunc TestMySQLAlchemyConn - remove TestMySQLAlchemy
cvonsteg 61d998f
added all MySQL test classes back
cvonsteg e454c35
Merge remote-tracking branch 'upstream/master' into sql-upsert
cvonsteg b4c058c
Merge remote-tracking branch 'upstream/master' into sql-upsert
cvonsteg 2ed4d32
Merge branch 'sql-upsert' of github.com:V0RT3X4/pandas into sql-upsert
cvonsteg c33d536
fix: merge master, resolve conflicts, move inserts out of nested tran…
cvonsteg b3bfbcc
Merge remote-tracking branch 'upstream/master' into sql-upsert
cvonsteg fafd646
Merge branch 'master' into sql-upsert
cvonsteg dbee26b
Merge branch 'sql-upsert' of github.com:V0RT3X4/pandas into sql-upsert
cvonsteg 3a04edd
Merge remote-tracking branch 'upstream/master' into sql-upsert
cvonsteg 0b03df7
Merge branch 'sql-upsert' of github.com:V0RT3X4/pandas into sql-upsert
cvonsteg f2d3596
Merge remote-tracking branch 'upstream/master' into sql-upsert
cvonsteg 529e5fb
chore: re-order imports
cvonsteg 6d718dc
remove unnecessary sort
cvonsteg 53e3565
undo sort rmv
cvonsteg 1bff71f
Merge remote-tracking branch 'upstream/master' into sql-upsert
cvonsteg 26c0b0f
feat: use updates instead of deletes
cvonsteg 59c76ac
chore: update tests to reflect new api
cvonsteg 21a87e1
Merge remote-tracking branch 'upstream/master' into sql-upsert
cvonsteg 286e8b8
feat: use on_conflict update methodology
cvonsteg 780fcea
Merge remote-tracking branch 'upstream/master' into sql-upsert
cvonsteg 70e0eb1
testing: add tests for single and composite primary keys
cvonsteg d4fc6d4
chore: add api tests for invalid if_exists, on_conflict args
cvonsteg c783496
chore: missing comma in tests
cvonsteg 4f4e9d9
chore: use backticks
cvonsteg e466ff3
Merge remote-tracking branch 'upstream/master' into sql-upsert
cvonsteg f2bc121
chore: use add constraint syntax
cvonsteg b9bfedc
tidy up
cvonsteg 43353f5
chore: merge upstream master
cvonsteg 6196c29
chore: merge master
cvonsteg b27449e
fix: add not null constraints to mysql tables
cvonsteg c8c1826
fix: change mysql type from TEXT to VARCHAR for indexing
cvonsteg e28cd9e
chore: merge master
cvonsteg 197e172
chore: use and_ inplace of tuple_
cvonsteg 6ebe9e8
Merge remote-tracking branch 'upstream/master' into sql-upsert
cvonsteg b95f6c9
Merge remote-tracking branch 'upstream/master' into sql-upsert
cvonsteg 8fa8e0e
chore: same change for update stmts
cvonsteg 1dee409
fix: primary keys no longer require names getter
cvonsteg 1f9fca7
chore: merge master
cvonsteg 2b30a9e
chore: merge master
cvonsteg a05937e
chore: remove wrong kwarg
cvonsteg 67143ff
chore: add multi-index lookup
cvonsteg 7e1148e
merge master
cvonsteg 11f201f
tests: fix on conflict with non append tests
cvonsteg 7f0b5dd
fix: pass on_conflict into prep_table
cvonsteg e5d5ce7
merge master
cvonsteg 8123cd7
fix: tests working
cvonsteg 26faabe
chore: check metadata bind before reflect
cvonsteg 9260eca
clean up docstrings
cvonsteg ad9f52f
merge: master
cvonsteg a63a77a
merge: master
cvonsteg a4df52b
Merge branch 'main' into sql-upsert
6190f6a
Merge branch 'main' into sql-upsert
75358ac
refactor: use
a3e1fb6
pre-commit fix
21ec99d
Merge branch 'pandas-dev:main' into sql-upsert
LSturtew 53d6cc7
clean up
a5fe55d
count updated rows for inserts with row conflict
636f6c2
rename overwrite to replace
67197c0
add type hints for new functions
b4b42f9
fix typo
3116cde
add typehints
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2773,6 +2773,7 @@ def to_sql( | |
con, | ||
schema=None, | ||
if_exists: str = "fail", | ||
on_row_conflict: str = "fail", | ||
index: bool_t = True, | ||
index_label=None, | ||
chunksize=None, | ||
|
@@ -2799,13 +2800,22 @@ def to_sql( | |
schema : str, optional | ||
Specify the schema (if database flavor supports this). If None, use | ||
default schema. | ||
if_exists : {'fail', 'replace', 'append'}, default 'fail' | ||
if_exists : {'fail', 'replace', 'append'},\ | ||
default 'fail' | ||
How to behave if the table already exists. | ||
|
||
* fail: Raise a ValueError. | ||
* replace: Drop the table before inserting new values. | ||
* append: Insert new values to the existing table. | ||
|
||
on_row_conflict : {'fail', 'overwrite', 'ignore'},\ | ||
default 'fail' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. needs a versionadded 1.5.0 |
||
How to behave if a row already exists. | ||
|
||
* fail: Raise ValueError. | ||
* overwrite: Overwrite the row with the incoming data. | ||
LSturtew marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* ignore: Ignore new data and keep existing data. | ||
|
||
index : bool, default True | ||
Write DataFrame index as a column. Uses `index_label` as the column | ||
name in the table. | ||
|
@@ -2850,6 +2860,9 @@ def to_sql( | |
ValueError | ||
When the table already exists and `if_exists` is 'fail' (the | ||
default). | ||
ValueError | ||
When the row already exists and `on_row_conflict` is 'fail' (the | ||
default). | ||
|
||
See Also | ||
-------- | ||
|
@@ -2942,6 +2955,7 @@ def to_sql( | |
con, | ||
schema=schema, | ||
if_exists=if_exists, | ||
on_row_conflict=on_row_conflict, | ||
index=index, | ||
index_label=index_label, | ||
chunksize=chunksize, | ||
|
Oops, something went wrong.
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.
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.
why are you u using row-continuation here? just leave it
can consider deprecating this and change the name to
if_table_exists
to be more obvious (but orthogonal)