-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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: Allow mapping as parameters for SQL DBAPI2 #6709
Conversation
@gpoulin2 Thanks for your very clear issue report and this quick PR! Would you also like to add a test for this? This could come in https://github.com/pydata/pandas/blob/master/pandas/io/tests/test_sql.py in BTW, we always advise to create a new branch when working an a new feature/bug fix (and not working on master), and also to |
I will put some test when I will have time (probably this weekend). To fix my git mess (sorry still not that used), you prefer that I reopen a new PR that is cleaner? |
@gpoulin2 No, a new PR won't be necessary I think. Just remove that last commit and then rebase properly and force push, something like (if you remotes upstream/origin):
|
I added tests and it makes me realized that the parameter list was also broken so I corrected appropriately. |
I just realized that my tests are wrongs. I correct this soon. |
Ah, yes, it is indeed a little bit more complicated .. But I was thinking, maybe we should only test this in the |
'read_parameters': { | ||
'sqlite': "SELECT * FROM iris WHERE Name=? AND SepalLength=?", | ||
'mysql': "SELECT * FROM iris WHERE Name=%s AND SepalLength=%s", | ||
'postgresql': "SELECT * FROM iris WHERE Name=%s AND SepalLength=%s" |
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.
The column names are case-sensitive, but eg Postgresql converts everything to lower case, unless you specify it as eg "Name"
(or Name
for mysql)
I think the docstring of |
I first put the test in SO should I remove the mysql and postgresql test or fix them? |
@gpoulin2 Ah, if you fetch latest master and rebase, you will see that there are now two versions of those tests: About the case sensitivity of MySQL, I am not an expert, but I think this is platform dependent (see http://dev.mysql.com/doc/refman/5.6/en/identifier-case-sensitivity.html). In any case, for PostgreSQL this is the reason the tests were failing. |
I corrected the tests and change the doctring of read_sql. The build succeed now. For the MySQL issue, I don't think is a case sensitivity issue (my project uses mysql on linux and is case sensitive). I think is more about the connector. mysql-connector-python probably do more job behind the scene than pymysql. |
That's possible. In any case, the tests are passing now! A last question, can you squash down to one or two commits? (https://github.com/pydata/pandas/wiki/Using-Git#fetch-and-then-rebase-interactively-to-squash-reword-fix-otherwise-change-some-commits) |
I think everything is good now. |
Thanks a lot! If you want to tackle some other problems, certainly do! |
BUG: Allow mapping as parameters for SQL DBAPI2
According to the DBAPI2.0 the parameters of the execute method can be a list or a mapping. The code in the master branch assume that this parameter is a list which can break working code. That's a regression compared to the pandas 0.13.1
Closes #6708