Skip to content

Conversation

@RahulHP
Copy link
Contributor

@RahulHP RahulHP commented Jan 15, 2016

Continued in #13252


This solves #11886
It checks whether the passed dtype variable is a dictionary.
If not, it creates a new dictionary with keys as the columns of the dataframe.
It then passes this dictionary to the pandasSQL_builder.

@jreback
Copy link
Contributor

jreback commented Jan 15, 2016

tests!

pandas/io/sql.py Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

I think flake8 will complain about this line. Need to get rid of the spaces around the curly braces.
Oh, also space after the common above in the isinstance check

Copy link
Contributor

Choose a reason for hiding this comment

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

Also is_dictlike (which isn't a perfect function but at least improvements will be encapsulated)

@jorisvandenbossche jorisvandenbossche added Enhancement IO SQL to_sql, read_sql, read_sql_query labels Jan 15, 2016
@jorisvandenbossche jorisvandenbossche added this to the 0.18.0 milestone Jan 15, 2016
@RahulHP
Copy link
Contributor Author

RahulHP commented Jan 16, 2016

Update: Writing the tests has been more difficult that I thought it would be. I am currently working on it though.

@jorisvandenbossche
Copy link
Member

@RahulHP For the test, best have a look at the existing test_dtype test (https://github.com/RahulHP/pandas/blob/to_sql-dictionary/pandas/io/tests/test_sql.py#L1502). You can see there how it is checked that the dtype is actually used in the database.
And maybe you can just add your test to that function.

@RahulHP
Copy link
Contributor Author

RahulHP commented Jan 17, 2016

Update: I added the new test and it passes the Travis build.

pandas/io/sql.py Outdated
Copy link
Member

Choose a reason for hiding this comment

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

missing space before 'If'

@RahulHP
Copy link
Contributor Author

RahulHP commented Jan 18, 2016

Edits done

@jreback
Copy link
Contributor

jreback commented Feb 1, 2016

can you rebase / squash

@RahulHP
Copy link
Contributor Author

RahulHP commented Feb 3, 2016

Done, I followed the Contributing guide as best as I could but I think I may have messed it up.

@jorisvandenbossche
Copy link
Member

@RahulHP There indeed slipped in some changes from other PRs. Normally, by doing exactly this, it should be solved:

git checkout to_sql-dictionary git fetch upstream git rebase upstream/master git push -f origin to_sql-dictionary 

In the rebase step, you will possibly need to resolve some conflicts

@jreback jreback removed this from the 0.18.0 milestone Feb 9, 2016
@jreback
Copy link
Contributor

jreback commented Mar 23, 2016

can you rebase/update

@RahulHP
Copy link
Contributor Author

RahulHP commented Mar 26, 2016

Sorry, I'll work on this in a few days.

@jreback
Copy link
Contributor

jreback commented May 20, 2016

pls rebase / update

@RahulHP
Copy link
Contributor Author

RahulHP commented May 21, 2016

I have created a new pull request here #13252

@jorisvandenbossche jorisvandenbossche added this to the No action milestone Jun 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement IO SQL to_sql, read_sql, read_sql_query

7 participants