Skip to content

BUG: read_sql_table can't find views #10750

Closed
@TomAugspurger

Description

@TomAugspurger

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    IO SQLto_sql, read_sql, read_sql_query

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions