skip to Main Content

Mysql – 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 db_engine = extrac_db.create_engine(Config.db_uri) db_connection = db_engine.connect()…

VIEW QUESTION

Docker with postgresql in flask web application (part 2)

I am building a Flask application in Python. I'm using SQLAlchemy to connect to PostgreSQL. In the flask application, I'm using this to connect SQLAlchemy to PostgreSQL engine = create_engine('postgresql://postgres:[mypassword]@db:5432/employee-manager-db') And this is my docker-compose.yml version: '3.8' services: backend: build:…

VIEW QUESTION

Postgresql – SQLAlchemy – column must appear in the GROUP BY clause or be used in an aggregate function

I am using sqlalchemy with postgresql, Tables Shape[id, name, timestamp, user_id]#user_id referring id column in user table User[id, name] this query - query1 = self.session.query(Shape.timestamp, Shape.name, User.id, extract('day', Shape.timestamp).label('day'), extract('hour', Shape.timestamp).label('hour'), func.count(Shape.id).label("total"), ) .join(User, User.id==Shape.user_id) .filter(Shape.timestamp.between(from_datetime, to_datetime)) .group_by(Shape.user_id) .group_by('hour') .all()…

VIEW QUESTION
Back To Top
Search