Skip to content

fixing the error in io/sql.py #1070

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

Closed
wants to merge 1 commit into from
Closed

Conversation

pengyu
Copy link
Contributor

@pengyu pengyu commented Apr 17, 2012

Not able to find an testing module in for io/sql.py. And I don't have time to create one now. So I paste the testing code below, which can be added into pandas later on.

#!/usr/bin/env python

from pymysql import connect
from pandas.io.sql import read_frame

con = connect(host='genome-mysql.cse.ucsc.edu', user='genome', db='mm9')
sql = 'select geneName as symbol, name as refSeq, chrom, strand, txStart, txEnd from refFlat limit 5'
df = read_frame(sql, con)
print df

@changhiskhan
Copy link
Contributor

Hi pengyu, you can check out /pandas/io/sql/tests/test_sql.py for the testing module for sql.py. Thanks.

@pengyu
Copy link
Contributor Author

pengyu commented Apr 17, 2012

I see the following test code for testing read_frame. Yet, it can't catch the error that I fixed. I'm not familiar with the testing in pandas. Could anybody improve the testing code so that it can catch this error?

 36         result = sql.read_frame("select * from test", con=self.db)

@changhiskhan
Copy link
Contributor

instead of passing in self.db you can use your own con object.
if you search around in the file you'll see that self.db is part of the initial test setup.

@pengyu
Copy link
Contributor Author

pengyu commented Apr 17, 2012

You misunderstood what I mean. I don't understand why line 36 did catch the error.

I tried my testing code on sqlite3, it works the same as pymysql and MySQLdb. So, theoretically speaking, even the testing code in line 36 is for sqlite3, as long as there is converge for the error, it should catch it.

But it seems that it doesn't cover the error. I can not quickly add some code (just based on sqlit3 instead of pymysql) to cover the error, as I'm not familiar with the testing framework.

@wesm
Copy link
Member

wesm commented May 7, 2012

Thanks. Changed this to only iterate over the result of cur.fetchall() if it's a non-list

@wesm wesm closed this May 7, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants