On Jun 11, 2010, at 8:55 PM, David Korz wrote:

> I have a table like such:
> 
> CREATE TABLE test (
> mykey integer not null,
> mydata double precision [2][10]
> ) without oids;
> 
> with a table defn like:
> 
> test = Table("test",metadata,
> Column("mykey",Integer,nullable=False),
> Column("mydata",PGArray(Float))
> )
> 
> I want to do a query like:
> 
> select mykey,sum(mydata[1][1]) from test group by mykey;
> 
> In SA I want to do something like:
> 
> query = select([test.c.mykey,func.sum(test.c.mydata[1]
> [1])],from_obj=[test]).group_by(test.c.mykey)
> 
> test.c.mydata can't be indexed so this is illegal. Is there a way I
> can access an array element in SA without just putting the actual SQL
> text in?

This is an unimplemented feature at the moment.    I've created a recipe that 
hand-rolls the syntax plus typing behavior as a @compiles recipe, which is 
available at:  http://www.sqlalchemy.org/trac/wiki/UsageRecipes/PGArrayIndex .


-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to