Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can SQLAlchemy use the "from only" clause of PostgreSQL?

I need to use the PostgreSQL only clause in a select query. Can I do that with SQLAlchemy?

like image 628
Brendan Abel Avatar asked Aug 17 '12 23:08

Brendan Abel


1 Answers

Yes, provided you use SQLAlchemy version 0.8.0 o newer (see issue 2506).

The ONLY keyword is implemented as a select hint:

result = table.select().with_hint(table, 'ONLY', 'postgresql')

or when using the ORM layer, on on a query object with:

session.query(...).with_hint(MappedClass, 'ONLY', 'postgresql')
like image 53
Martijn Pieters Avatar answered Nov 10 '22 12:11

Martijn Pieters