BUG: to_sql convert index name to string (#15404)
State: closed

…rs with numeric index name - needs conversion to string

 - [x] closes #15404
 - [x] tests passed
 - [x] passes ``git diff upstream/master | flake8 --diff``
 - [x] whatsnew entry


Labels:
name: Bug
name: IO SQL
description: to_sql, read_sql, read_sql_query

Comments:
@redbullpeter Thanks!

Can you add a test case for this? (in pandas/tests/io/test_sql.py) You can put the test in the `_TestSQLApi` class
While writing the test cases I discovered I jumped the gun on this. Will probably have to rescind the pull request.
OK done. For a while there it seemed like I was going down a rabbit hole that got more confusing as I picked at it.
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/15423?src=pr&el=h1) Report
> Merging [#15423](https://codecov.io/gh/pandas-dev/pandas/pull/15423?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/5a8883b965610234366150897fe8963abffd6a7c?src=pr&el=desc) will **decrease** coverage by `-0.01%`.
> The diff coverage is `100%`.


```diff
@@            Coverage Diff             @@
##           master   #15423      +/-   ##
==========================================
- Coverage   90.37%   90.37%   -0.01%     
==========================================
  Files         135      135              
  Lines       49440    49454      +14     
==========================================
+ Hits        44681    44693      +12     
- Misses       4759     4761       +2
```


| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/15423?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/sql.py](https://codecov.io/gh/pandas-dev/pandas/compare/5a8883b965610234366150897fe8963abffd6a7c...e9a4f3a12643234d7d95ff61aa80677d2f918b82?src=pr&el=tree#diff-cGFuZGFzL2lvL3NxbC5weQ==) | `94.79% <100%> (ø)` | :white_check_mark: |
| [pandas/tseries/index.py](https://codecov.io/gh/pandas-dev/pandas/compare/5a8883b965610234366150897fe8963abffd6a7c...e9a4f3a12643234d7d95ff61aa80677d2f918b82?src=pr&el=tree#diff-cGFuZGFzL3RzZXJpZXMvaW5kZXgucHk=) | `95.32% <ø> (-0.1%)` | :x: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/compare/5a8883b965610234366150897fe8963abffd6a7c...e9a4f3a12643234d7d95ff61aa80677d2f918b82?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.82% <ø> (-0.05%)` | :x: |
| [pandas/core/generic.py](https://codecov.io/gh/pandas-dev/pandas/compare/5a8883b965610234366150897fe8963abffd6a7c...e9a4f3a12643234d7d95ff61aa80677d2f918b82?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ2VuZXJpYy5weQ==) | `96.33% <ø> (ø)` | :white_check_mark: |
| [pandas/tools/concat.py](https://codecov.io/gh/pandas-dev/pandas/compare/5a8883b965610234366150897fe8963abffd6a7c...e9a4f3a12643234d7d95ff61aa80677d2f918b82?src=pr&el=tree#diff-cGFuZGFzL3Rvb2xzL2NvbmNhdC5weQ==) | `97.62% <ø> (ø)` | :white_check_mark: |
| [pandas/io/excel.py](https://codecov.io/gh/pandas-dev/pandas/compare/5a8883b965610234366150897fe8963abffd6a7c...e9a4f3a12643234d7d95ff61aa80677d2f918b82?src=pr&el=tree#diff-cGFuZGFzL2lvL2V4Y2VsLnB5) | `79.64% <ø> (+0.24%)` | :white_check_mark: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/15423?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/15423?src=pr&el=footer). Last update [5a8883b...e9a4f3a](https://codecov.io/gh/pandas-dev/pandas/compare/5a8883b965610234366150897fe8963abffd6a7c...e9a4f3a12643234d7d95ff61aa80677d2f918b82?src=pr&el=footer&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
@redbullpeter Thanks a lot!
@redbullpeter Whoops, forgot to ask you for a whatsnew note, so quickly added it: https://github.com/pandas-dev/pandas/commit/54b6c6e1c443b992a1df3443669a59dbe430271f