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

423 Views Asked by At

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 ?

1

There are 1 best solutions below

0
On

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

create_engine(connection_url, enable_from_linting=False)