'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 :

<ipython-input-2-fe928e97d8b6>:1: SAWarning: SELECT statement has a cartesian product between FROM element(s) "A" and FROM element "B"

However... A cartesian product (called cross product elsewhere...) is exactly what I am doing and want to do...

So how to suppress this warning ?



Solution 1:[1]

The warning can be suppressed by setting enable_from_linting to False when creating the engine:

create_engine(connection_url, enable_from_linting=False)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 snakecharmerb