BUG: `read_sql_table` can't find views #10750

Closed
TomAugspurger opened this Issue Aug 4, 2015 · 2 comments

Comments

Projects
None yet
3 participants
Contributor

TomAugspurger commented Aug 4, 2015

pd.read_sql_table(tablename, engine) won't be able to find tablename if it's actually a view.

This should be a one line change to https://github.com/pydata/pandas/blob/b281e6570bc3bb3773520eff0b6965d5691e3ba2/pandas/io/sql.py#L340

    meta = MetaData(con, schema=schema)
    try:
        meta.reflect(only=[table_name])
    except sqlalchemy.exc.InvalidRequestError:
        raise ValueError("Table %s not found" % table_name)

just adding the keyword argument views=True from http://docs.sqlalchemy.org/en/rel_1_0/core/metadata.html I don't think there will be any negative consequences to this, but I don't use sqlalchemy MetaData objects that often.

TomAugspurger added this to the Next Major Release milestone Aug 4, 2015

Contributor

IamGianluca commented Aug 8, 2015

I'm working on this. At the moment I'm building a unit test which works for all dbs (sqlite, postgres, mysql). The change you suggested seems to work @TomAugspurger

Closed by #10803

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment