-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
FIX: to_sql takes the boolean column as text column #7678
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
Conversation
to_sql
takes the boolean column as text columnto_sql
takes the boolean column as text column
to_sql
takes the boolean column as text column
@yelite Thanks for the contribution! Can you add a test for it (look in io/tests/test_sql.py)? You can for example take the example you were working with where you experienced the issue, and slim this down to a small test case. Just ask if something is not clear for this. @jreback There isn't already a function like this somewhere? |
this is already in master (recently added) |
@yelite indeed, it is already here: https://github.com/pydata/pandas/blob/master/pandas/core/common.py#L2255 |
@jorisvandenbossche |
@yelite I wanted to say your test would fail because of the index, but you already adapated it! Can you add a line in doc/source/v0.14.1.txt in the bug fixes section for this? |
self.conn, flavor='sqlite', index=False) | ||
result = sql.read_sql_table('test_frame5', self.conn) | ||
|
||
self.assertTrue((self.test_frame2.dtypes==result.dtypes).all(), |
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.
this should be tm.assert_frame_equal(self.test_frame2,result)
https://travis-ci.org/pydata/pandas/jobs/29317980 Does this difference between |
so the returned data is unicode. so 2 solns:
e.g. in sqlalchemy (sort of manuall), I usually do
|
@jreback @jorisvandenbossche |
For the whatsnew note, that is OK. And the column names of the original dataframe and the result from |
Travis is green, so merging. |
FIX: to_sql takes the boolean column as text column
https://travis-ci.org/pydata/pandas/jobs/29341707 I have seen this happen if something weird is passed to an let's see if it repeats |
hmm, the next travis builds have the same (but strange that for the PR it had not this issue) |
In the original code,
com.is_bool(arr_or_dtype)
checks whetherarr_or_dtype
is a boolean value instead of a boolean dtype.A new function
is_bool_dtype
is added topandas.core.common
to fix this bug.