-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
ENH: Add table prefixes to to_sql method #60409
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
…andas into table_prefixes
Thanks for the PR, but this seems to only work with SQLAlchemy, meaning we won't get the same behavior for our ADBC drivers. I don't think this is worth pursuing unless there is a way to avoid fragmenting features across those two different areas |
I took a look into the ADBC implementation. |
I did some testing and was able to implement the feature partially for Now the question is:
I personally prefer the first option, because I connect to |
Can you check if there is an open issue for this upstream in the arrow-adbc repository? I think it may be of interest to them to handle more than just the temporary case. ADBC releases are pretty quick, so if that is implemented upstream it benefits the entire ecosystem, and likely wouldn't be a long turnaround to get into pandas |
That is a very good point. It wold be very beneficial, if both |
It looks like the
@WillAyd What are your thoughts on this? |
I don't think its worth adding to pandas if the various backends cannot both fully support it; we may have to document instead how you could do it with more low-level SQLAlchemy operations, but to have the pandas API only offer this for SQLAlchemy but not ADBC makes the abstraction of the pandas API more complicated |
And what about a reduced parameter |
This pull request is stale because it has been open for thirty days with no activity. Please update and respond to this comment if you're still interested in working on this. |
I'm still interested in working on this. |
@WillAyd, what's your thought on this? Having a parameter |
I think that would be a reasonable solution across the implementations |
pandas/io/sql.py
Outdated
try: | ||
_ = self.pd_sql.read_query(query) | ||
return True | ||
except ProgrammingError: |
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.
Does sqlalchemy not provide a higher level abstraction than ProgrammingError or OperationalError? I'm not sure I understand the distinction between those, and I am not sure if they would catch all possible errors thrown by sqlalchemy either
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.
The is a higher abstraction possible with DatabaseError
.
_ = self.pd_sql.read_query(query) | ||
return True | ||
except ProgrammingError: | ||
# Some DBMS (e.g. postgres) require a rollback after a caught exception |
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.
The DMBS-specific features are something we want to avoid in pandas, as maintaining compatability on those is not a core specialty of our team. Does sqlalchemy not handle this natively?
meta data. The existence is duck tested by a SELECT statement.""" | ||
from adbc_driver_manager import ProgrammingError | ||
|
||
# sqlite doesn't allow a rollback at this point |
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.
Similar comment as before - we really want to avoid putting DBMS-specific logic into our implementation
Thanks for the pull request, but it appears to have gone stale. If interested in continuing, please merge in the main branch, address any review comments and/or failing tests, and we can reopen. |
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.This PR adds a
prefixes
parameter to theto_sql
method and passes it down to the underlyingsqlalchemy.Table
class. It takes into account that temporary tables are not stored in a database's meta data and adds temporary table specific methods for_exists_temporary
and_drop_temporary_table
.Unfortunately, temporary tables don't work with null pooling, so I had to create additional sqlalchemy fixtures with the default pooling.
TODO:
SQLDatabase.check_case_sensitive
checks the databases's meta data. It will never find a temporary table and always throw a Warning. - I disabled case sensitivity checks for temporary tables.