[sqlalchemy] Re: ForeignKey not saved - sqlite3, TG1.1

2009-06-06 Thread Adam Yee
Thanks Mike, it's working now. But I'm curious, how was the foreignkey erased from the previous entry upon each newly added blog? What does .append do that keeps the foreignkeys saved? On Jun 6, 5:24 am, Mike Conley wrote: > Looks like the culprit is: > user.blogs = [Blog(title=input['blog_titl

[sqlalchemy] Re: union with two different orders

2009-06-06 Thread Michael Bayer
On Jun 6, 2009, at 11:39 AM, naktinis wrote: > > I think this was not the case, since I didn't expect the merged result > to be ordered. > > To be more precise, the query looks like: > q1 = Thing.query().filter(...).order_by(Thing.a.desc()).limit(1) > q2 = Thing.query().filter(...).order_by(Thin

[sqlalchemy] Re: Session is already flushing

2009-06-06 Thread Michael Bayer
usually it means mutiple threads are hitting a single Session and/or connection. keep in mind all objects attached to a session are an extension of that session's state and similarly cannot be shared among threads unless detached. On Jun 6, 2009, at 1:03 AM, Michael Mileusnich wrote: > I

[sqlalchemy] Re: union with two different orders

2009-06-06 Thread naktinis
I think this was not the case, since I didn't expect the merged result to be ordered. To be more precise, the query looks like: q1 = Thing.query().filter(...).order_by(Thing.a.desc()).limit(1) q2 = Thing.query().filter(...).order_by(Thing.a.asc()).limit(1) q = q1.union(q2).order_by(Thing.id).all(

[sqlalchemy] Re: union with two different orders

2009-06-06 Thread Adrian von Bidder
On Saturday 06 June 2009 14.18:33 naktinis wrote: > I want to use union on two queries, which have different order: > q1 = Thing.query().order_by(Thing.a) > q2 = Thing.query().order_by(Thing.b) > q = q1.union(q2).all() SQL doesn't work as you think it does here. A UNION does not concatenate the

[sqlalchemy] Re: ForeignKey not saved - sqlite3, TG1.1

2009-06-06 Thread Mike Conley
Looks like the culprit is: user.blogs = [Blog(title=input['blog_title'] this replaces your user.blogs relation with a single entry list containing the last Blog try this to add a Blog to the relation list user.blogs.append(Blog(title=input['blog_title')) -- Mike Conley On Fri, Jun 5, 2009 at

[sqlalchemy] union with two different orders

2009-06-06 Thread naktinis
I want to use union on two queries, which have different order: q1 = Thing.query().order_by(Thing.a) q2 = Thing.query().order_by(Thing.b) q = q1.union(q2).all() But after this query I get MySQL error message "Incorrect usage of UNION and ORDER BY". I guess that this could be because having "SELE

[sqlalchemy] Re: Reading in single columns as numpy arrays

2009-06-06 Thread Can Xue
2009/6/5 Thomas > > Hi, > > I'm trying to read in single columns from an SQL database as 1D numpy > arrays with the correct types. So a FLOAT column would be returned as > a numpy.float32 array, etc. Is there an easy way to do this? > Maybe you have to define your own Float datatype using NumPy