[sqlalchemy] Lack of parentheses in subquery syntax

2009-03-21 Thread Victor Lin
Hi, I am using Elixir that based on SQLAlchemy to do some query like this: onAirs = db.session.query(model.OnAir.user_id).subquery() sites = db.session.query(model.Site).filter(model.Site.user_id.in_ (onAirs)) But it act not exactly like what I think. I got a syntax error: ProgrammingError:

[sqlalchemy] Is it possible to exclude spefcific column in result?

2009-03-21 Thread Victor Lin
Hi, I got some query like this: sites = db.session.query(model.Site, func.sum (model.ProxyOnAir.listeners).label('listeners')).\ join(model.OnAir).\ outerjoin(model.ProxyOnAir).\ group_by(model.Site.user_id).\ order_by('listeners') The

[sqlalchemy] Cannot Operate on a Closed Cursor (Error)

2009-03-21 Thread NWGGUY
Sorry to bother, I am trying to run the tutorial (Define and Create a Table) http://www.sqlalchemy.org/docs/05/ormtutorial.html and get the following error after executing the statement: metadata.create_all(engine) Cannot operate on a closed cursor Running Windows XP, Python 2.5.1,

[sqlalchemy] Re: Cannot Operate on a Closed Cursor (Error)

2009-03-21 Thread Michael Bayer
I'd suggest you use the sqlite3 built in to the Python distribution, otherwise use the latest trunk of SQLa as this bug is fixed against the most recent release of pysqlite2. On Mar 21, 2009, at 3:32 AM, NWGGUY wrote: Sorry to bother, I am trying to run the tutorial (Define and Create

[sqlalchemy] Re: Lack of parentheses in subquery syntax

2009-03-21 Thread Michael Bayer
its looking for a scalar, not a subquery(). I dont think query() has as_scalar() yet so use a select([model.OnAir.user_id]).as_scalar() for this. On Mar 21, 2009, at 4:30 AM, Victor Lin wrote: Hi, I am using Elixir that based on SQLAlchemy to do some query like this: onAirs =

[sqlalchemy] Re: Is it possible to exclude spefcific column in result?

2009-03-21 Thread Michael Bayer
you never need any columns in the columns clause of a SELECT to control filtering/ordering of rows. place the criterion you'd like in the ORDER BY. query.order_by(func.sum(colname)) On Mar 21, 2009, at 9:01 AM, Victor Lin wrote: Hi, I got some query like this: sites =

[sqlalchemy] Re: Lack of parentheses in subquery syntax

2009-03-21 Thread Michael Bayer
I've committed a change in 5852 that will allow subquery() to be used in a scalar context in a WHERE clause - as_scalar() is now called on Alias objects. On Mar 21, 2009, at 4:30 AM, Victor Lin wrote: Hi, I am using Elixir that based on SQLAlchemy to do some query like this: onAirs =

[sqlalchemy] Re: 0.5.2 seems to always roll back with mssql

2009-03-21 Thread davidlmontgomery
Thanks Mike and Michael for your suggestions. remove() will roll back any existing transaction Yes, this is what I am seeing. but the commit() call previously will issue a COMMIT for any pending data. And this COMMIT is succeeding with 0.4.8, but it is not succeeding with 0.5.2. the

[sqlalchemy] Re: Declarative with Enthoughts Traits framework.

2009-03-21 Thread Christiaan Putter
Hi svilen, Thanks for your advice, going through your code helped a lot in understanding how SA works. I've gotten traited classes to behave like classes generated by SA's declarative extension. After a lot of stepping through code I realised the main problem was that SA removes values from an

[sqlalchemy] Re: 0.5.2 seems to always roll back with mssql

2009-03-21 Thread Michael Bayer
Ive booted up my virtual windows machine and it all works for me. note that dsn is now the default interpretation of host in 0.5, i.e. connect using mssql://dsn. perhaps you've got multiple database instances being accesed across SQLA versions. On Mar 21, 2009, at 8:01 PM,