Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Error AttributeError: 'Connection' object has no attribute 'fetchall'

I have the following SQL database details:

import sqlalchemy as sch
from config import Config

db_uri = os.environ["SQLALCHEMY_DATABASE_URI"] + os.environ["DB_NAME"]

in the env file I have these

SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://*****:*****@instance-amazonaws.com:3306/'
DB_NAME = 'DB_NAME'

Now

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

db_engine = extrac_db.create_engine(Config.db_uri)
db_connection = db_engine.connect()

When I try this query:

db_connection.execute("select count(*) from table")
query_result = db_connection.fetchall()

It gives the following error:

AttributeError: 'Connection' object has no attribute 'fetchall'

What is the problem here!!!?

>Solution :

Wild guess:

query = db_connection.execute("select count(*) from table")
query_result = query.fetchall()
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading