SQLAlchemy 2.0 (released 2023-01-26) requires that raw SQL queries be wrapped by sqlalchemy.text.

The general solution for this error message is to pass the query text to sqlalchemy.text()

from sqlalchemy import text
...

query = text("SELECT * FROM some_table WHERE column1 > 1")

However in this case the OP is using pandasql, which expects a string. There does not seem to be a straightforward way to make pandasql compatible with SQLAlchemy >= 2.0, and the package seems to be unmaintained, so the only solutions are to find a fork that has fixed the problem (there are some), fork the project yourself and fix it, or downgrade your SQLAlchemy installation using your Python package manager. For example, if you use pip:

python3 -m pip install --upgrade 'sqlalchemy<2.0'
Answer from snakecharmerb on Stack Overflow
🌐
Reddit
reddit.com › r/learnpython › how do i fix this : attributeerror: 'str' object has no attribute 'current'
r/learnpython on Reddit: How do i fix this : AttributeError: 'str' object has no attribute 'current'
December 7, 2023 -

There is something wrong with this function. It shows no errors, but when I try to run it, It says AttributeError: 'str' object has no attribute 'current'. (BTW, i am trying to run it as a flet on spyder)

def leapyears(e):

days_in_month = {1: 31, 3: 31, 4: 30, 5:31, 6: 30, 7: 31, 8: 31, 9: 30, 10: 31, 11: 30, 12: 31 }

month = int(EnterMonth_text.value)

year = int(EnterYear_text.value)

if year % 100 == 0:

if year % 400 == 0:

leap_year = True

elif year % 4 == 0:

leap_year = True

else:

leap_year = False

if month == 2 :

if leap_year:

days_in_month[2] = 29

else:

days_in_month[2]= 28

output_textfield.value= days_in_month[month]

page.update()

Discussions

db.perform_query fails when called with a string: sqlalchemy not an executable object/no attribute '_execute_on_connection'
db.perform_query fails when called with a string: sqlalchemy not an executable object/no attribute '_execute_on_connection'#159 More on github.com
🌐 github.com
1
October 14, 2024
AttributeError: 'Engine' object has no attribute 'execute'
Describe the bug I am getting: Traceback (most recent call last): File "C:\Program Files\JetBrains\PyCharm Community Edition 2022.1.3\plugins\python-ce\helpers\pydev\pydevd.py", line 1496, in _exec pydev_imports.execfile(file, globals, l... More on github.com
🌐 github.com
6
January 27, 2023
sqlite - python - 'str' object has no attribute 'execute' - Stack Overflow
First time python user here, be gentle.... ;-) Python 2.6 on OSX Got a class which just has some wrappers around sqlite... here it is from pysqlite2 import dbapi2 as sqlite class SqliteDB: More on stackoverflow.com
🌐 stackoverflow.com
AttributeError: 'str' object has no attribute 'get'
The formatting of your post is hella weird - how about you just include a link to your replit · For the catplot, you need to add a line fig=fig.fig before saving - as the test is not designed for standard object sns is returning · Am sorry for my formatting errors Jagaya, am new to this . More on forum.freecodecamp.org
🌐 forum.freecodecamp.org
0
0
December 2, 2021
🌐
GitHub
github.com › yhat › pandasql › issues › 102
'str' object has no attribute '_execute_on_connection' · Issue #102 · yhat/pandasql
February 1, 2023 - A few days ago I started getting these error messages when trying to run sqldf : AttributeError: 'str' object has no attribute '_execute_on_connection' sqlalchemy.exc.ObjectNotExecutableError: Not an executable object The error message p...
Author   posidonius
🌐
YouTube
youtube.com › watch
Handling AttributeError: 'str' object has no attribute '_execute_on_connection' in Python - YouTube
Summary: Learn how to resolve the common error "AttributeError: 'str' object has no attribute '_execute_on_connection'" frequently faced by Python programmer...
Published   September 5, 2024
Views   40
🌐
GI Chow
gichow.com › 2023 › 04 › 16 › pandasql-broken-in-google-colab-quick-fix
Pandasql broken in Google Colab – Quick fix | GI Chow
May 4, 2023 - Pandasql AttributeError Last week a time-saving Python program I had been running successfully for several months in the Google Colab Jupyter notebook environment suddenly failed with a curious error. https://stackoverflow.com/questions/75464271/attributeerror-str-object-has-no-attribute-execute-on-connection The cause - an upgrade to a package (SQLAlchemy) that a library I was using (pandasql) depended upon had broken the library.
🌐
GitHub
github.com › sqlalchemy › sqlalchemy › issues › 9161
AttributeError: 'Engine' object has no attribute 'execute' · Issue #9161 · sqlalchemy/sqlalchemy
January 27, 2023 - I am getting: Traceback (most recent call last): File "C:\Program Files\JetBrains\PyCharm Community Edition 2022.1.3\plugins\python-ce\helpers\pydev\pydevd.py", line 1496, in _exec pydev_imports.execfile(file, globals, locals) # execute the script File "C:\Program Files\JetBrains\PyCharm Community Edition 2022.1.3\plugins\python-ce\helpers\pydev_pydev_imps_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "C:/Development/Projects/DeepTradingAI/deeptrading/utils/db.py", line 3050, in code = get_day_code(ticker="DJI", day_code_column="TwoDayCode") File "C:/Development/Projects/DeepTradingAI/deeptrading/utils/db.py", line 3025, in get_day_code record = db_connection.execute(statement) AttributeError: 'Engine' object has no attribute 'execute'
Author   nectario
🌐
HatchJS
hatchjs.com › home › how to fix attributeerror: ‘str’ object has no attribute ‘_execute_on_connection’
How to Fix AttributeError: 'str' Object Has No Attribute '_execute_on_connection'
January 5, 2024 - The `AttributeError: ‘str’ ... method on a string object. To fix this error, you need to make sure that you are calling the method on a connection object....
Find elsewhere
🌐
freeCodeCamp
forum.freecodecamp.org › python
AttributeError: 'str' object has no attribute 'get' - Python - The freeCodeCamp Forum
December 2, 2021 - The formatting of your post is hella weird - how about you just include a link to your replit · For the catplot, you need to add a line fig=fig.fig before saving - as the test is not designed for standard object sns is returning · Am sorry for my formatting errors Jagaya, am new to this .
🌐
GitHub
github.com › sinaptik-ai › pandas-ai › issues › 1183
when i note "direct_sql": True, error:Not an executable object: "\nSELECT \n ELECTRY_NAME,\n ...... · Issue #1183 · sinaptik-ai/pandas-ai
May 29, 2024 - result = {} sql_query = """ SELECT ...packages\sqlalchemy\engine\base.py", line 1414, in execute meth = statement._execute_on_connection ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'str' object has no attribute '_execute_on_connection'...
Published   May 29, 2024
Author   colorwlof
🌐
GitHub
github.com › sqlalchemy › sqlalchemy › issues › 9155
problem with new version (2.0.0) on .execute() · Issue #9155 · sqlalchemy/sqlalchemy
January 27, 2023 - Please read https://msg.pyyaml.org/load for full details. self.cfg = yaml.load(ymlfile) Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1410, in execute meth = statement._execute_on_connection AttributeError: 'str' object has no attribute '_execute_on_connection' The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/service/app/src/orangeryos.py", line 5, in <module> from rest.rest_service import app_service File "/service/app/src/rest/rest_service.py", line 10, in <module
Author   agn-7
🌐
GitHub
github.com › geopandas › geopandas › issues › 2681
BUG: to_postgis() option if_exists="append" fails to find SRID · Issue #2681 · geopandas/geopandas
December 19, 2022 - with eng.connect() as conn: pd.read_sql(sqlalchemy.text("SELECT Find_SRID('schema_name', 'table_name', 'geom');"), conn) Output: find_srid 0 6344 · AttributeError: 'str' object has no attribute '_execute_on_connection' The above exception was the direct cause of the following exception: Traceback (most recent call last): File "<stdin>", line 2, in <module> File "/home/user/.local/share/virtualenvs/env/lib/python3.8/site-packages/geopandas/geodataframe.py", line 1931, in to_postgis geopandas.io.sql._write_postgis( File "/home/user/.local/share/virtualenvs/env/lib/python3.8/site-packages/geopan
Author   george-j-thomas
🌐
GitHub
github.com › cloud-utils › sqlalchemy-aurora-data-api › issues › 43
SQLAlchemy Version 2.0.0 breaks reflected tables · Issue #43 · cloud-utils/sqlalchemy-aurora-data-api
January 27, 2023 - chalice local --host=0.0.0.0 --no-autoreload Found credentials in shared credentials file: ~/.aws/credentials Traceback (most recent call last): File "/root/helloworld/venv/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1410, in execute meth = statement._execute_on_connection AttributeError: 'str' object has no attribute '_execute_on_connection' The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/root/helloworld/venv/lib/python3.8/site-packages/chalice/cli/__init__.py", line 636, in main return cli(obj={}) File "/root/hel
Author   ArielZamparini-REISys
🌐
Esri Community
community.esri.com › t5 › arcgis-api-for-python-questions › str-object-has-no-attribute › td-p › 1053478
Solved: 'str' object has no attribute - Esri Community
September 14, 2021 - The clone_items function takes a list of Items. It seems like you are passing in the string item ids instead.
🌐
GitHub
github.com › home-assistant › home-assistant-notebooks › issues › 26
Getting Started Error · Issue #26 · home-assistant/home-assistant-notebooks
November 1, 2023 - File /usr/local/lib/python3.11/dist-packages/sqlalchemy/engine/base.py:1414, in Connection.execute(self, statement, parameters, execution_options) 1412 meth = statement._execute_on_connection 1413 except AttributeError as err: -> 1414 raise exc.ObjectNotExecutableError(statement) from err 1415 else: 1416 return meth( 1417 self, 1418 distilled_parameters, 1419 execution_options or NO_OPTIONS, 1420 )
Author   yozh
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-fix-attributeerror-object-has-no-attribute
How to fix AttributeError: object has no attribute - GeeksforGeeks
July 23, 2025 - To understand this error, we first have to know how to read the error message effectively. It typically consists of two parts: "AttributeError" and "Object has no attribute." The former indicates the type of error, and the latter suggests that the attribute we are trying to access does not exist for the object.
🌐
Quora
quora.com › What-can-I-do-if-I-have-attribute-error-str-object-has-no-attribute-re
What can I do if I have attribute error: 'str' object has no attribute 're'? - Quora
Summary Replace calls to a non‑existent .re on strings with calls to functions/methods that exist for the types involved, avoid shadowing the re module name, and verify variable types before invoking methods. ... RelatedHow do you resolve an "error in Keras model about attributeerror: 'str' object has no attribute 'decode'" (Python, Keras, development)?