Skip to content

Fix #35484 - re-allow sqlalchemy declarative system to use % in read_sql. #36275

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

Closed
wants to merge 3 commits into from

Conversation

machow
Copy link

@machow machow commented Sep 10, 2020

I was going nuts trying to keep track of all the cases, so tossed them into a table! I didn't have time to explicitly check v1.05, so would be helpful if someone could verify that column (or I may be able to loop back to it)!

query v1.05 v.1.1 PR issue
no params, % #34211 (merged)
no params, %% #35871
params, % psycopg/psycopg2#827
params, %%
sqla declarative, % #35484

@jbrockmendel
Copy link
Member

@TomAugspurger any idea who to ping about sqlalchemy review?

@TomAugspurger
Copy link
Contributor

TomAugspurger commented Sep 24, 2020 via email

@github-actions
Copy link
Contributor

This pull request is stale because it has been open for thirty days with no activity. Please update or respond to this comment if you're still interested in working on this.

@github-actions github-actions bot added the Stale label Oct 25, 2020
@jbrockmendel
Copy link
Member

@john-bodley can you take a look at this

@john-bodley
Copy link
Contributor

I guess this is a known issue with SQLAlchemy (using 1.2.8 per the Pandas specs) using the default connection for certain dialects, i.e.,

from sqlalchemy import create_engine

engine = create_engine('postgresql://postgres:@localhost:5433/postgres', echo=False) 
engine.execute("SELECT 1 % 2")  # TypeError: 'dict' object does not support indexing

versus the raw-connection:

from sqlalchemy import create_engine

engine = create_engine('postgresql://postgres:@localhost:5433/postgres', echo=False) 
cursor = engine.raw_connection().cursor() 
cursor.execute("SELECT 1 % 2")
cursor.fetchone()  # (1,)

Googling the issue it seems taking the sql.text(...) approach as proposed by @machow seems to be a commonly recommended solution.

@jreback jreback added IO SQL to_sql, read_sql, read_sql_query and removed Stale labels Nov 26, 2020
Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you write a whatsnew entry (1.2). i think this would make evaluating this easier.

def test_read_sql_no_parameter_with_percent(self):
self._read_sql_iris_no_parameter_with_percent()

@pytest.mark.xfail
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add an explict xfail / message or reason

@jreback
Copy link
Contributor

jreback commented Nov 26, 2020

can you also merge master

@machow
Copy link
Author

machow commented Nov 27, 2020

@john-bodley @jreback thanks for your feedback. I'll have some time after next week--will add a whatsnew entry and bring things up to date.

@github-actions
Copy link
Contributor

This pull request is stale because it has been open for thirty days with no activity. Please update or respond to this comment if you're still interested in working on this.

@github-actions github-actions bot added the Stale label Dec 28, 2020
@jreback
Copy link
Contributor

jreback commented Dec 28, 2020

closing this as stale, though maybe fixed by #37534 (in 1.2) in any event.

if this is not the case @machow you can create a new PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IO SQL to_sql, read_sql, read_sql_query Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: read_sql no longer works simply with SqlAlchemy selectables and a quick fix
5 participants