You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After upgrading to Airflow 2.8.2 one of our DAGs started failing. It seems to come from updating Pandas to 2.2.1 while SQLAlchemy is still on 1.4.X. According to Pandas docs v2.2.1 needs at least 2.0.
File "./virtualenvs/airflow/lib/python3.11/site-packages/pandas/io/sql.py", line 2670, in execute
cur = self.con.cursor()
^^^^^^^^^^^^^^^
AttributeError: 'Connection' object has no attribute 'cursor'
What you think should happen instead?
No response
How to reproduce
Upgrade to 2.8.2 using the Constraint File for Python 3.11
Can you please elaborate how it reappeared? What makes you think so ?
We exclude #37748 from 2.8.3 and originally I did not add this tests #37779 as 2.8.3 milestone ¯\_(ツ)_/¯.
The things happen, just need to think how we might prevent this into the future.
The constraint is no more and it's breaking pandas x SQLAlchemy in Airflow 3 right now.
Now
df.to_sql(
"table",
con=engine,
)
... gives me:
AttributeError: 'Engine' object has no attribute 'cursor'
$ docker run --rm --pull=always --entrypoint='''apache/airflow:3.0.3-python3.12' bash -c 'pip list --format=freeze'| grep -Ei '^(pandas|sqlalchemy)=='3.0.3-python3.12: Pulling from apache/airflowDigest: sha256:66d35503f78e8c87de2db43f0a3311efd26a5d34584599509a8bd90fb308adc7Status: Image is up to date for apache/airflow:3.0.3-python3.12pandas==2.2.3SQLAlchemy==1.4.54
Breaking pandas x SQLAlchemy in Airflow 3 right now.
You can upgrade things independently from constraints. But this has been fixed in #53535 and new constraints are coming in 3.0.4 - right after we release current wave of providers that is being voted.
BTW. The new providers are released - if you - for example try to install latest common.sql provider - it will not allow to upgrade pandas beyond what is supported.
The constraints-3-0 generated today (and those will be used for 3.0.4) contain this:
As you can see - pandas is limited in constraints to 2.1.4 now.
@potiuk, what pandas version should be used with Airflow 3.1.7 (latest) and Python 3.12? I tried the one from constraints (https://raw.githubusercontent.com/apache/airflow/constraints-3.1.7/constraints-3.12.txt), i.d. pandas=2.3.3, but had the same error (AttributeError: 'Connection' object has no attribute 'cursor').
Everything works with pandas=2.1.4 🤔, although I'm afraid that this version is old.
Did you install everything with constraints ? Including providers and other reps or you installed things independently ? If independently then sometimes it might be trial and error because some dependencies might not work with others. I recommend to install airflow following our installation guide (with everything you need with constraints) and then downgrade or upgrade any other dependencies as needed and test. This is exactly what our recommendations at installation page are. If you do it differently, there are too many variables to help you and give you concrete answers for potential incompatibilities between other dependencies
Yes, I did, but I used uv add instead of uv pip install (as the installation guide recommends) since the latter doesn't update pyproject.toml which I need to maintain for running tests. I noticed that the constraints state SQLAlchemy==2.0.46, whereas I have sqlalchemy==1.4.54 in my test env. So, uv add doesn't work correctly for some reason 😢.
UPD:
Fixed the versions: uv add "sqlalchemy==2.0.46" "pandas==2.3.3", everything works now.
The constraints are only active in the command they are used. This is how constraints work. If you do uv add or whatever without constraints they can feely upgrade or downgrade other deps. And even If you specify constraints and install only one or two packages - those constraints only apply to things being explicitly installed, if uv decides to downgrade packages that are not specified in the installation command, they do not follow constraints. If you notice that uv downgrades some package with add and you want to keep it, you need to add this package explicitly in your add command I guess
Activity
aa-matthias commentedon Feb 27, 2024
pandas-dev/pandas#57049
potiuk commentedon Feb 27, 2024
We updated constraints, and re-built the images. When users will be using reference image or install airflow 2.8.2 following our recommendation (with constraints https://airflow.apache.org/docs/apache-airflow/stable/installation/installing-from-pypi.html ) - they should get Pandas 2.1.4 when installing Airflow 2.8.2. Thansk @aa-matthias for notifying us! 1
aa-matthias commentedon Mar 12, 2024
@potiuk - looks like the issue reappeared in Airflow 2.8.3 ?
potiuk commentedon Mar 12, 2024
Can you please elaborate how it reappeared? What makes you think so ?
Taragolis commentedon Mar 12, 2024
We exclude #37748 from 2.8.3 and originally I did not add this tests #37779 as 2.8.3 milestone
¯\_(ツ)_/¯.The things happen, just need to think how we might prevent this into the future.
Taragolis commentedon Mar 12, 2024
So for Python > 3.8 we generate constraints, build docker image with pandas greater or equal than 2.2
potiuk commentedon Mar 12, 2024
Let me see - I can check and regenerate the images again. I think the way to do it in the future is to "remember" :) . There is no other way
lucasfcnunes commentedon Aug 1, 2025
@potiuk
The constraint is no more and it's breaking pandas x SQLAlchemy in Airflow 3 right now.
Now
... gives me:
PS: When
SQLAlchemy<2,pandas<2.2is a must.Refs:
potiuk commentedon Aug 1, 2025
Not sure what it means
You can upgrade things independently from constraints. But this has been fixed in #53535 and new constraints are coming in 3.0.4 - right after we release current wave of providers that is being voted.
lucasfcnunes commentedon Aug 2, 2025
I meant these
pandasto<2.2#37748potiuk commentedon Aug 3, 2025
BTW. The new providers are released - if you - for example try to install latest common.sql provider - it will not allow to upgrade pandas beyond what is supported.
The constraints-3-0 generated today (and those will be used for 3.0.4) contain this:
As you can see - pandas is limited in constraints to 2.1.4 now.
TopCoder2K commentedon Feb 25, 2026
@potiuk, what pandas version should be used with Airflow 3.1.7 (latest) and Python 3.12? I tried the one from constraints (https://raw.githubusercontent.com/apache/airflow/constraints-3.1.7/constraints-3.12.txt), i.d.
pandas=2.3.3, but had the same error (AttributeError: 'Connection' object has no attribute 'cursor').Everything works with
pandas=2.1.4🤔, although I'm afraid that this version is old.potiuk commentedon Feb 25, 2026
Did you install everything with constraints ? Including providers and other reps or you installed things independently ? If independently then sometimes it might be trial and error because some dependencies might not work with others. I recommend to install airflow following our installation guide (with everything you need with constraints) and then downgrade or upgrade any other dependencies as needed and test. This is exactly what our recommendations at installation page are. If you do it differently, there are too many variables to help you and give you concrete answers for potential incompatibilities between other dependencies
potiuk commentedon Feb 25, 2026
Likely you have some sqlalchemy version that conflicts
TopCoder2K commentedon Feb 25, 2026
@potiuk, thank you for the fast answer!
Yes, I did, but I used
uv addinstead ofuv pip install(as the installation guide recommends) since the latter doesn't updatepyproject.tomlwhich I need to maintain for running tests. I noticed that the constraints stateSQLAlchemy==2.0.46, whereas I havesqlalchemy==1.4.54in my test env. So,uv adddoesn't work correctly for some reason 😢.UPD:
Fixed the versions:
uv add "sqlalchemy==2.0.46" "pandas==2.3.3", everything works now.potiuk commentedon Feb 25, 2026
The constraints are only active in the command they are used. This is how constraints work. If you do uv add or whatever without constraints they can feely upgrade or downgrade other deps. And even If you specify constraints and install only one or two packages - those constraints only apply to things being explicitly installed, if uv decides to downgrade packages that are not specified in the installation command, they do not follow constraints. If you notice that uv downgrades some package with add and you want to keep it, you need to add this package explicitly in your add command I guess