Hi Simon,

It all works. All I need is how to do:

Model.query.options(load_only(Model.array[1])).all()   ?


Thanks


On Tue, Nov 8, 2016 at 10:56 AM, Simon King <si...@simonking.org.uk> wrote:

> On Tue, Nov 8, 2016 at 9:31 AM, Dorian Hoxha <dorian.ho...@gmail.com>
> 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 a topic in the
> Google Groups "sqlalchemy" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/sqlalchemy/dkOnyUkgRX4/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> sqlalchemy+unsubscr...@googlegroups.com.
> To post to this group, send email to sqlalchemy@googlegroups.com.
> Visit this group at https://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to