ENH: to_sql() add parameter "method" to control insertions method (#8…
State: closed

…953)

- [x] closes #8953 
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry


Labels:
name: Enhancement
name: Performance
description: Memory or execution speed performance
name: IO SQL
description: to_sql, read_sql, read_sql_query

Comments:
Hello @schettino72! Thanks for updating the PR.







Cheers ! There are no PEP8 issues in this Pull Request. :beers: 

##### Comment last updated on December 27, 2018 at 23:51 Hours UTC
- Added docs
- removed COPY implementation from code and added on docs

There is only one problem with flake8 complaining about a long.
The problem is that it is a url link, not sure how to break in into multiple lines...

Note: I am targeting this to 0.24, not 0.23.x. 
IMO an addition of parameter should not be made a on bug release.
Otherwise code written for 0.32.2 using the new parameter would not run on 0.23.1...
> Note: I am targeting this to 0.24, not 0.23.x.

@schettino72 : That's exactly what we would do as well.  Good call!
@schettino72 : Looks like you have a lint error according to Travis <a href="https://travis-ci.org/pandas-dev/pandas/jobs/390088220">here</a>.
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/21401?src=pr&el=h1) Report
> Merging [#21401](https://codecov.io/gh/pandas-dev/pandas/pull/21401?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/415012f4f38ca0cf41717c51e49bd2349cba09a8?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/21401/graphs/tree.svg?width=650&height=150&src=pr&token=eZ4WkYLtcO)](https://codecov.io/gh/pandas-dev/pandas/pull/21401?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master   #21401   +/-   ##
=======================================
  Coverage   91.89%   91.89%           
=======================================
  Files         153      153           
  Lines       49596    49596           
=======================================
  Hits        45576    45576           
  Misses       4020     4020
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.29% <ø> (ø)` | :arrow_up: |
| #single | `41.86% <ø> (ø)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/21401?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/generic.py](https://codecov.io/gh/pandas-dev/pandas/pull/21401/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ2VuZXJpYy5weQ==) | `96.12% <ø> (ø)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/21401?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/21401?src=pr&el=footer). Last update [415012f...1e5d1cc](https://codecov.io/gh/pandas-dev/pandas/pull/21401?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/21401?src=pr&el=h1) Report
> Merging [#21401](https://codecov.io/gh/pandas-dev/pandas/pull/21401?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/5a0c91e5a5bc61c71da08d6968d973255829678d?src=pr&el=desc) will **increase** coverage by `<.01%`.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/21401/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/21401?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #21401      +/-   ##
==========================================
+ Coverage   92.22%   92.22%   +<.01%     
==========================================
  Files         169      169              
  Lines       50897    50903       +6     
==========================================
+ Hits        46940    46946       +6     
  Misses       3957     3957
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.65% <ø> (ø)` | :arrow_up: |
| #single | `42.29% <ø> (-0.01%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/21401?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/generic.py](https://codecov.io/gh/pandas-dev/pandas/pull/21401/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ2VuZXJpYy5weQ==) | `96.84% <ø> (ø)` | :arrow_up: |
| [pandas/core/arrays/categorical.py](https://codecov.io/gh/pandas-dev/pandas/pull/21401/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2NhdGVnb3JpY2FsLnB5) | `95.56% <0%> (+0.03%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/21401?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/21401?src=pr&el=footer). Last update [5a0c91e...f4ffbfc](https://codecov.io/gh/pandas-dev/pandas/pull/21401?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

Thanks for quick review and tips. Ready for next round :grin: 
@schettino72 : Seems like you have test failures...
lgtm. @jorisvandenbossche merge when satisfied.
lgtm. ping @jorisvandenbossche 
@schettino72 would love to see this this ship - think we'll get it into the next release?
What's the status on this?

@schettino72 there's a merge conflict with master, if you could merge master and push.
@schettino72 The magnificent you are the only hope for this unbelievable feature to be delivered at this wonderful release.
Sorry, I dont have the time now to work on this.

It seems the conflict is only on README file.
IMO should be resolved at the time the pull request is actually merged (by someone with write access), not something i can do.
Otherwise I might be playing catch up forever...
The bottleneck is actually me (or another core dev) doing a new review, or if we think it is not needed it should be ready to merge if the merge conflicts is fixed.

But taking another look now.
Merged master.

On Tue, Oct 23, 2018 at 2:13 PM eduardo naufel schettino <
notifications@github.com> wrote:

> Sorry, I dont have the time now to work on this.
>
> It seems the conflict is only on README file.
> IMO should be resolved at the time the pull request is actually merged (by
> someone with write access), not something i can do.
> Otherwise I might be playing catch up forever...
>
> —
> You are receiving this because you commented.
> Reply to this email directly, view it on GitHub
> <https://github.com/pandas-dev/pandas/pull/21401#issuecomment-432381507>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/ABQHIi9VCOM3XtPLrmWDWOsN0krDWKvhks5un2pvgaJpZM4UhSR4>
> .
>

# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/21401?src=pr&el=h1) Report
> Merging [#21401](https://codecov.io/gh/pandas-dev/pandas/pull/21401?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/2a097061700e2441349cafd89348c9fc8d14ba31?src=pr&el=desc) will **decrease** coverage by `<.01%`.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/21401/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/21401?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #21401      +/-   ##
==========================================
- Coverage    92.3%    92.3%   -0.01%     
==========================================
  Files         163      163              
  Lines       51954    51969      +15     
==========================================
+ Hits        47957    47968      +11     
- Misses       3997     4001       +4
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.7% <ø> (-0.01%)` | :arrow_down: |
| #single | `43.01% <ø> (+0.01%)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/21401?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/generic.py](https://codecov.io/gh/pandas-dev/pandas/pull/21401/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ2VuZXJpYy5weQ==) | `96.62% <ø> (ø)` | :arrow_up: |
| [pandas/core/arrays/datetimelike.py](https://codecov.io/gh/pandas-dev/pandas/pull/21401/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2RhdGV0aW1lbGlrZS5weQ==) | `95.93% <0%> (-0.43%)` | :arrow_down: |
| [pandas/core/indexes/period.py](https://codecov.io/gh/pandas-dev/pandas/pull/21401/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9wZXJpb2QucHk=) | `92.75% <0%> (-0.33%)` | :arrow_down: |
| [pandas/core/indexes/timedeltas.py](https://codecov.io/gh/pandas-dev/pandas/pull/21401/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy90aW1lZGVsdGFzLnB5) | `90.11% <0%> (-0.31%)` | :arrow_down: |
| [pandas/tseries/offsets.py](https://codecov.io/gh/pandas-dev/pandas/pull/21401/diff?src=pr&el=tree#diff-cGFuZGFzL3RzZXJpZXMvb2Zmc2V0cy5weQ==) | `96.69% <0%> (-0.26%)` | :arrow_down: |
| [pandas/core/arrays/datetimes.py](https://codecov.io/gh/pandas-dev/pandas/pull/21401/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2RhdGV0aW1lcy5weQ==) | `97.6% <0%> (-0.18%)` | :arrow_down: |
| [pandas/core/indexes/accessors.py](https://codecov.io/gh/pandas-dev/pandas/pull/21401/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9hY2Nlc3NvcnMucHk=) | `91% <0%> (-0.09%)` | :arrow_down: |
| [pandas/core/indexes/datetimes.py](https://codecov.io/gh/pandas-dev/pandas/pull/21401/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9kYXRldGltZXMucHk=) | `96.31% <0%> (-0.02%)` | :arrow_down: |
| [pandas/core/indexes/multi.py](https://codecov.io/gh/pandas-dev/pandas/pull/21401/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9tdWx0aS5weQ==) | `95.58% <0%> (ø)` | :arrow_up: |
| ... and [14 more](https://codecov.io/gh/pandas-dev/pandas/pull/21401/diff?src=pr&el=tree-more) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/21401?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/21401?src=pr&el=footer). Last update [2a09706...19ce379](https://codecov.io/gh/pandas-dev/pandas/pull/21401?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

@schettino72 can you merge master
Waiting for this! Thanks guys.
@jreback Merged master, changed the `method` default to `None` and all green. Functionality looks good to me, but not sure if there's any doc followups that needs to be made. 
@jreback Added a test for the example in `io.rst` and all green.
@TomAugspurger ?
+1 aside from the example. I'll push a commit updating it.
Thanks @jreback, @TomAugspurger.

And thank you @schettino72!  
Thank you all! Looking forward to using this :) 
Hooray! Thanks :)