-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: read_sql_table unable to read views #54185
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
Conversation
@@ -2411,7 +2413,15 @@ def to_sql( | |||
|
|||
def has_table(self, name: str, schema: str | None = None) -> bool: | |||
wld = "?" | |||
query = f"SELECT name FROM sqlite_master WHERE type='table' AND name={wld};" | |||
query = f""" |
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.
is something like this equivalent here opposed to the sql?
self.meta.reflect(bind=self.con)
return name in metadata.tables.keys()
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.
Yes, I believe so https://www.sqlite.org/schematab.html
Since this is the sqlite3 backend unfortunately we can't meta.reflect
@@ -1655,7 +1655,7 @@ def read_table( | |||
SQLDatabase.read_query | |||
|
|||
""" | |||
self.meta.reflect(bind=self.con, only=[table_name]) | |||
self.meta.reflect(bind=self.con, only=[table_name], views=True) |
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.
guessing this isnt too expensive performance wise that we will now start reflecting all tables by default (include views/mat views) just thinking if this will impact performance for current users.
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.
Yeah I'm assuming it's negligible relative to the query or IO, especially since the old implementation was able to access views too
Hey @mroeschke ! Didn't realise we don't have read_sql_table implemented for sqllite! Looks great to me, some minor thoughts above :) |
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.Looks like
read_sql_table
isn't implemented for sqllite, but this PR enableread_sql
to work with views