On Tue, Nov 8, 2016 at 9:31 AM, Dorian Hoxha <[email protected]> wrote:
> So,
>
> I want to do "SELECT array[1] FROM table;". Meaning to select only 1
> element. Is this possible (didn't find by searching
> docs,mailing-list,google).
> Though I can do it by normal query.
>

I haven't used arrays with postgresql, so I've no idea if this works,
but for documentation you probably want to start here:

http://docs.sqlalchemy.org/en/latest/core/type_basics.html#sqlalchemy.types.ARRAY

According to those docs, if you've declared a table with a column
using the ARRAY type, you should be able to query elements of the
array using python indexing operators. For example:

    table = sa.Table('mytable', metadata, sa.Column('array',
sa.ARRAY(sa.Integer)))
    sa.select([table.c.array[1]])

Hope that helps,

Simon

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to