Raghav Patnecha
Raghav Patnecha

Reputation: 736

What is the equivalent of PostgreSQL @> operator in SQLAlchemy

I am using PostgreSQL database for a program and came across the contains range (@>) operator.

As I am converting a PostgreSQL query in python SQLAlchemy, therefore, I need to convert @> into its SQLAlchemy equivalent.

Upvotes: 6

Views: 4851

Answers (1)

Raghav Patnecha
Raghav Patnecha

Reputation: 736

I used op(). The operator @> is equivalent to "in" in python. But similar results could be achieved using .op('@>') through SQLAlchemy. For example:

Places.query.filter(loc_amsterdam.op("@>")(loc_company))

Upvotes: 12

Related Questions