Skip to content
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

BUG: writing invalid table names to sqlite #16464

Merged
merged 2 commits into from
Jun 1, 2017
Merged

BUG: writing invalid table names to sqlite #16464

merged 2 commits into from
Jun 1, 2017

Conversation

huguesv
Copy link
Contributor

@huguesv huguesv commented May 23, 2017

I verified that the test exposes the bug prior to the fix for bug #13206.

Pandas from master

>>> import sqlite3
>>> import pandas as pd
>>> import numpy as np
>>> conn = sqlite3.connect(':memory:')
>>> df = pd.DataFrame({'A': [0, 1, 2], 'B': [0.2, np.nan, 5.6]})
>>> df.to_sql('d1187b08-4943-4c8d-a7f6-6c06b7cb9509', conn, index=False)
>>> 

Pandas 0.13.1

>>> import sqlite3
>>> import pandas as pd
>>> import numpy as np
>>> conn = sqlite3.connect(':memory:')
>>> df = pd.DataFrame({'A': [0, 1, 2], 'B': [0.2, np.nan, 5.6]})
>>> df.to_sql('d1187b08-4943-4c8d-a7f6-6c06b7cb9509', conn, index=False)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Projects\Sprints\PandasVirtualEnvLatest\PandasVirtualEnvLatest\oldpy27\lib\site-packages\pandas\core\frame.py", line 1261, in to_sql
    self, name, con, flavor=flavor, if_exists=if_exists, **kwargs)
  File "C:\Projects\Sprints\PandasVirtualEnvLatest\PandasVirtualEnvLatest\oldpy27\lib\site-packages\pandas\io\sql.py", line 226, in write_frame
    cur.execute(create)
OperationalError: near "-": syntax error
>>> 

# GH 13206
df = DataFrame({'A': [0, 1, 2], 'B': [0.2, np.nan, 5.6]})
df.to_sql('d1187b08-4943-4c8d-a7f6-6c06b7cb9509', self.conn, index=False)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you read this back and compare

@jreback jreback added the IO SQL to_sql, read_sql, read_sql_query label May 23, 2017
@jreback jreback changed the title Add test for bug #13206. BUG: writing invalid table names to sqlite May 23, 2017
@codecov
Copy link

codecov bot commented May 26, 2017

Codecov Report

Merging #16464 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #16464   +/-   ##
=======================================
  Coverage   90.42%   90.42%           
=======================================
  Files         161      161           
  Lines       51027    51027           
=======================================
  Hits        46142    46142           
  Misses       4885     4885
Flag Coverage Δ
#multiple 88.26% <ø> (ø) ⬆️
#single 40.17% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 04356a8...bc3a99d. Read the comment docs.

@codecov
Copy link

codecov bot commented May 26, 2017

Codecov Report

Merging #16464 into master will increase coverage by 0.37%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #16464      +/-   ##
==========================================
+ Coverage   90.42%   90.79%   +0.37%     
==========================================
  Files         161      161              
  Lines       51027    51063      +36     
==========================================
+ Hits        46142    46365     +223     
+ Misses       4885     4698     -187
Flag Coverage Δ
#multiple 88.63% <ø> (+0.37%) ⬆️
#single 40.15% <ø> (-0.02%) ⬇️
Impacted Files Coverage Δ
pandas/io/feather_format.py 85.71% <0%> (-2.17%) ⬇️
pandas/plotting/_converter.py 63.23% <0%> (-1.82%) ⬇️
pandas/core/categorical.py 95.5% <0%> (-0.42%) ⬇️
pandas/core/frame.py 97.66% <0%> (-0.03%) ⬇️
pandas/core/reshape/pivot.py 95.08% <0%> (ø) ⬆️
pandas/core/resample.py 96.09% <0%> (+0.01%) ⬆️
pandas/core/ops.py 91.69% <0%> (+0.01%) ⬆️
pandas/plotting/_core.py 81.92% <0%> (+0.02%) ⬆️
pandas/core/generic.py 92.26% <0%> (+0.13%) ⬆️
pandas/core/series.py 94.9% <0%> (+0.18%) ⬆️
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 04356a8...bc3a99d. Read the comment docs.

@huguesv
Copy link
Contributor Author

huguesv commented May 26, 2017

@jreback I've added the additional verification, and all checks are now passing.

@TomAugspurger TomAugspurger added this to the 0.21.0 milestone Jun 1, 2017
@TomAugspurger TomAugspurger added the Testing pandas testing functions or related to the test suite label Jun 1, 2017
@TomAugspurger TomAugspurger merged commit 7b106e4 into pandas-dev:master Jun 1, 2017
@TomAugspurger
Copy link
Contributor

Thanks!

Kiv pushed a commit to Kiv/pandas that referenced this pull request Jun 11, 2017
* Add test for bug pandas-dev#13206.

* Improve test by reading back the values from sql and comparing. Also fixes coding style violation.
stangirala pushed a commit to stangirala/pandas that referenced this pull request Jun 11, 2017
* Add test for bug pandas-dev#13206.

* Improve test by reading back the values from sql and comparing. Also fixes coding style violation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IO SQL to_sql, read_sql, read_sql_query Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants