-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH: Add 'truncate' option for if_exists arg for DataFrame.to_sql method #52961
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
ENH: Add 'truncate' option for if_exists arg for DataFrame.to_sql method #52961
Conversation
…r-existing-table-in-to_sql
Amazing! |
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.
Thanks for the PR, but it's preferred to use a sqlalchemy function to truncate instead of running raw SQL since it's not guaranteed for the SQL to be database dialect agnostic
Thanks @mroeschke ! I couldn't find anything in the SQLalchemy docs for truncate specifically but they do have |
I suppose |
Thanks for the pull request, but it appears to have gone stale. If interested in continuing, please merge in the main branch, address any review comments and/or failing tests, and we can reopen. |
This is my first ever PR on an open source project. This one seemed pretty small & straight forward so I gave it go. Just merged main into the branch so it is conflict free. Please let me know if there's anything else I can do to help get this merged!
See issue #37210 for more context but this essentially gives a user the option to truncate an existing table before inserting new rows into it via the
DataFrame.to_sql
method.doc/source/whatsnew/v2.1.0.rst
file if fixing a bug or adding a new feature.