From f5f02798cbefa82867595d28bfa8c22f4ec3282b Mon Sep 17 00:00:00 2001 From: shirzady1934 Date: Thu, 13 Mar 2025 10:47:26 +0330 Subject: [PATCH 1/8] issue 1166 Update test to use SQLAlchemy 2.0 compatible select statement --- tests/test_io.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/test_io.py b/tests/test_io.py index cca219c42..7114ba613 100644 --- a/tests/test_io.py +++ b/tests/test_io.py @@ -1415,9 +1415,12 @@ class Temp(Base): Session = sqlalchemy.orm.sessionmaker(engine) with Session() as session: - pd.read_sql( - session.query(Temp.quantity).statement, session.connection() - ) + stmt = sqlalchemy.select(Temp.quantity) + pd.read_sql(stmt, session.connection()) + + # pd.read_sql( + # #session.query(Temp.quantity).statement, session.connection() + # ) def test_sqlalchemy_text() -> None: From 563d30e1525c0a9f642a38040e5ff40b94ebcc15 Mon Sep 17 00:00:00 2001 From: shirzady1934 Date: Thu, 13 Mar 2025 14:10:22 +0330 Subject: [PATCH 2/8] issue 1166 deleted commented --- tests/test_io.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/test_io.py b/tests/test_io.py index 7114ba613..d99470771 100644 --- a/tests/test_io.py +++ b/tests/test_io.py @@ -1418,10 +1418,6 @@ class Temp(Base): stmt = sqlalchemy.select(Temp.quantity) pd.read_sql(stmt, session.connection()) - # pd.read_sql( - # #session.query(Temp.quantity).statement, session.connection() - # ) - def test_sqlalchemy_text() -> None: with ensure_clean() as path: From 8f5e207eddae1c8f4cf2b9d31b2c199e6597614b Mon Sep 17 00:00:00 2001 From: shirzady1934 Date: Thu, 13 Mar 2025 15:26:56 +0330 Subject: [PATCH 3/8] Revert "issue 1166 deleted commented" This reverts commit 563d30e1525c0a9f642a38040e5ff40b94ebcc15. --- tests/test_io.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/test_io.py b/tests/test_io.py index d99470771..7114ba613 100644 --- a/tests/test_io.py +++ b/tests/test_io.py @@ -1418,6 +1418,10 @@ class Temp(Base): stmt = sqlalchemy.select(Temp.quantity) pd.read_sql(stmt, session.connection()) + # pd.read_sql( + # #session.query(Temp.quantity).statement, session.connection() + # ) + def test_sqlalchemy_text() -> None: with ensure_clean() as path: From 69815968d31bfdff4efc551d01406e62cf115a35 Mon Sep 17 00:00:00 2001 From: shirzady1934 Date: Thu, 13 Mar 2025 15:27:21 +0330 Subject: [PATCH 4/8] Revert "issue 1166 Update test to use SQLAlchemy 2.0 compatible select statement" This reverts commit f5f02798cbefa82867595d28bfa8c22f4ec3282b. --- tests/test_io.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/tests/test_io.py b/tests/test_io.py index 7114ba613..cca219c42 100644 --- a/tests/test_io.py +++ b/tests/test_io.py @@ -1415,12 +1415,9 @@ class Temp(Base): Session = sqlalchemy.orm.sessionmaker(engine) with Session() as session: - stmt = sqlalchemy.select(Temp.quantity) - pd.read_sql(stmt, session.connection()) - - # pd.read_sql( - # #session.query(Temp.quantity).statement, session.connection() - # ) + pd.read_sql( + session.query(Temp.quantity).statement, session.connection() + ) def test_sqlalchemy_text() -> None: From 2846f3dd310bb61eeeb1739f237478cadb0591f9 Mon Sep 17 00:00:00 2001 From: shirzady1934 Date: Thu, 13 Mar 2025 15:33:12 +0330 Subject: [PATCH 5/8] issue 1166 added extra possible type UpdateBase to _SQLStatement --- pandas-stubs/io/sql.pyi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pandas-stubs/io/sql.pyi b/pandas-stubs/io/sql.pyi index d53f9b052..862acac2b 100644 --- a/pandas-stubs/io/sql.pyi +++ b/pandas-stubs/io/sql.pyi @@ -15,6 +15,7 @@ from pandas.core.frame import DataFrame import sqlalchemy.engine from sqlalchemy.orm import FromStatement import sqlalchemy.sql.expression +from sqlalchemy.sql.expression import UpdateBase from typing_extensions import TypeAlias from pandas._libs.lib import NoDefault @@ -33,6 +34,7 @@ _SQLStatement: TypeAlias = ( | sqlalchemy.sql.expression.TextClause | sqlalchemy.sql.Select | FromStatement + | UpdateBase ) @overload From adb3090f13e4e83403db1dfdd0c4da9d99dd3a0e Mon Sep 17 00:00:00 2001 From: shirzady1934 Date: Thu, 13 Mar 2025 23:47:33 +0330 Subject: [PATCH 6/8] issue 1166 used sqlalchemy.sql.expression pattern --- pandas-stubs/io/sql.pyi | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pandas-stubs/io/sql.pyi b/pandas-stubs/io/sql.pyi index 862acac2b..bf30b3f84 100644 --- a/pandas-stubs/io/sql.pyi +++ b/pandas-stubs/io/sql.pyi @@ -15,7 +15,6 @@ from pandas.core.frame import DataFrame import sqlalchemy.engine from sqlalchemy.orm import FromStatement import sqlalchemy.sql.expression -from sqlalchemy.sql.expression import UpdateBase from typing_extensions import TypeAlias from pandas._libs.lib import NoDefault @@ -34,7 +33,7 @@ _SQLStatement: TypeAlias = ( | sqlalchemy.sql.expression.TextClause | sqlalchemy.sql.Select | FromStatement - | UpdateBase + | sqlalchemy.sql.expression.UpdateBase ) @overload From 4adf5a993b4e8505e7c88617e3216d4be4a6e10b Mon Sep 17 00:00:00 2001 From: shirzady1934 Date: Fri, 14 Mar 2025 01:19:12 +0330 Subject: [PATCH 7/8] issue 1166 change SQLAlchemy version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 2570e0898..d75d4b52e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -59,7 +59,7 @@ xarray = ">=22.6.0" tabulate = ">=0.8.10" jinja2 = ">=3.1" scipy = { version = ">=1.9.1", python = "<3.14" } -SQLAlchemy = ">=2.0.12" +SQLAlchemy = ">2.0.39" types-python-dateutil = ">=2.8.19" beautifulsoup4 = ">=4.12.2" html5lib = ">=1.1" From 2f647cf87968ab6862b087662fa92988e1d56958 Mon Sep 17 00:00:00 2001 From: "Mohammad Moein (Nima) Shirzady" <58934667+shirzady1934@users.noreply.github.com> Date: Fri, 14 Mar 2025 01:27:40 +0330 Subject: [PATCH 8/8] Update pyproject.toml Co-authored-by: Irv Lustig --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 652d54894..9b967bf59 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -59,7 +59,7 @@ xarray = ">=22.6.0" tabulate = ">=0.8.10" jinja2 = ">=3.1" scipy = { version = ">=1.9.1", python = "<3.14" } -SQLAlchemy = ">2.0.39" +SQLAlchemy = ">=2.0.39" types-python-dateutil = ">=2.8.19" beautifulsoup4 = ">=4.12.2" html5lib = ">=1.1"