Category "sqlalchemy"

How to fix error in db.create_all() in docker?

Trying to launch postgres and flask in docker. Postgres is working ok as i see. But flask is cancelling to work properly The head of log is here: Traceback (mo

sqlalchemy return constant dict in select

I am using sqlalchemy with MySql. I need to return a dict in select. Adding that dict value to fetched data is not an option. Is there any way in sqlalchemy or

Multiple flask calls in single pytest having different databases

So I'm trying to test an endpoint in flask that I need to call multiple times in one test. The issue I am having is that on the second request the objects I pla

How to use a standalone Operations instance and rollback changes?

The Alembic documentation states that "a standalone Operations instance can be made for use cases external to regular Alembic migrations by passing in a Migrati

Hybrid expression for relationship of relationship

I have three models linked by a relationship chain. An entry has requests and a partner. So every request has a related partner by this: class Request(db.Model)

Parameter substitution when calculating the distance between each row and a common point results in psycopg2 parse error

I have two models with no relation Port and a WareHouse each with a lat and long fields. I want to be able to get the distance for each warehouse from the Port

Inserting rows into Microsoft SQL Server using pandas raises precision error

I am trying to insert data into a mssql database. I needed as fast method for this so I set the fast_executemany param to true. The upload works fine for most p

How to suppress warnings on cross join select without where clause in sqlalchemy?

When doing something like : import sqlalchemy as sa with session() as S: print(S.execute(sa.orm.select(A, B)).all()) sqlalchemy display this warning : <i

ForeignKey serialized as empty dict and not getting populated with data

I've two models Profile & Product representing One-Many relationship. One profile can have many products. I'm serializing all the fields. The column which h

Query difference between db.session.query and Model.query in flask-SQLAlchemy

The database is near 5 millions rows. I declare a model like below: class Amodel(db.Model): id = db.Column(db.Integer, primary_key=True) date = db.Col

SQLAlchemy column name with space

I'm trying to filter a table on a column that contain spaces. ... events = database_session.query(table) events.filter(table.column with space == 'xvalue') &

Join same table twice in SQLALCHEMY selecting only some columns

Consider I have 2 models: class User(db.Model): __tablename__ = 'user' id = db.Column(db.Integer, primary_key=True) email = db.Column(db.String(255)

How to get query data converting foreign table's another column

I'm now using sqlalchemy, fastapi develop some REST API. And facing some problem to join multiple tables I have 2 tables as below [campaigns] class Campaign(Bas

fastapi using ORM not able to convert to pandas

I've been developing a fastapi way to query my database, instead of directly using SQL with pg. For some reason, I'm having issues converting the ORM query retu

`pd.read_sql(sql, engine)` raises NotImplementedError: This method is not implemented for SQLAlchemy 2.0

I tried to create a pandas DataFrame directly from my sqlserver database using an sqlalchemy engine: engine = create_engine(URL_string, echo=False, future=True)

Cannot create SQLAlchemy engine, getting error "loaded 'mysqldb' is not async"

I'm trying to replace Databases with SQLAlchemy 1.4 async. When I try to make the engine I get the following error: sqlalchemy.exc.InvalidRequestError: The asyn

Error with default value in enum field when define model class

Hello I have the following model: class Status(Enum): scheduled: 'scheduled' recording: 'recording' complete: 'complete' failed: 'failed' @dat

SQLAlchemy use calculated column

I want some code like below: distance = (Robot.pose_x)**2 + (Robot.pose_y)**2 robot_filtered = session.query(Robot).filter(distance > 100).all() But it give

Error: trying to push Table SQLAlchemy models to my production heroku-server using Alembic

I am trying to push my SQLAlchemy-models to create Tables in my heroku-postgres-database. I use this command: heroku run alembic upgrade head It starts to Run

Using asyncio extension with SQLite backend broken by version upgrade

An upgrade from SQLAlchemy version 1.4.0b2 to 1.4.0b3 results in the following error when attempting to connect to a SQLite engine, using the asyncio extension.