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: handle no rows returns from a sql query #3745

Closed
jreback opened this issue Jun 3, 2013 · 2 comments
Closed

BUG: handle no rows returns from a sql query #3745

jreback opened this issue Jun 3, 2013 · 2 comments
Labels
Bug IO Data IO issues that don't fit into a more specific label IO SQL to_sql, read_sql, read_sql_query
Milestone

Comments

@jreback
Copy link
Contributor

jreback commented Jun 3, 2013

related to #3523

@hayd hayd mentioned this issue Jul 8, 2013
20 tasks
@jreback
Copy link
Contributor Author

jreback commented Mar 22, 2014

@jorisvandenbossche @hayd new sql list?

@jorisvandenbossche
Copy link
Member

This seems to be solved in master in the meantime (works for both sqlalchemy and sqlite3 fallback):

In [1]: import pandas as pd

In [2]: import sqlite3

In [3]: import sqlalchemy

In [4]: pd.__version__ 
Out[4]: '0.14.1-474-g744daa7'

In [5]: con = sqlite3.connect(':memory:')

In [6]: engine = sqlalchemy.create_engine('sqlite:///:memory:')

In [7]: df = pd.DataFrame({'a':[1,2,3], 'b':[2,3,4]})

In [8]: df.to_sql('test', engine, index=False, if_exists='replace')

In [9]: df.to_sql('test', con, index=False, if_exists='replace')

In [10]: pd.read_sql_query("SELECT * FROM test WHERE a < 0", engine)
Out[10]: 
Empty DataFrame
Columns: [a, b]
Index: []

In [11]: pd.read_sql_query("SELECT * FROM test WHERE a < 0", con)
Out[11]: 
Empty DataFrame
Columns: [a, b]
Index: []

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug IO Data IO issues that don't fit into a more specific label IO SQL to_sql, read_sql, read_sql_query
Projects
None yet
Development

No branches or pull requests

2 participants