[sqlalchemy] Problems with NOT IN and layered subqueries

2009-09-08 Thread Seth
I'm experiencing some problems when trying to do layered subqueries, especially relating to doing a NOT IN (SUBQUERY). I can't get SQLAlchemy to put the sub-query SELECT inside parenthesis, so my query is failing with an error. I'm trying to do a query across three tables, with some rather

[sqlalchemy] Re: Help on Custom Type with TypeEngine (Oracle SDO_GEOM)

2009-09-08 Thread Nicolas Dufrane
thanks for this complete answer ! I will investigate a little more in existing projects like geoalchemy, mapfish to find a nice way to implement oracle spatial support. regards Nicolas 2009/9/7 Sanjiv Singh singhsanj...@gmail.com On Mon, Sep 7, 2009 at 8:25 PM, Michael

[sqlalchemy] Re: How to use julianday for datetime storing with sqlite

2009-09-08 Thread Slava Tutushkin
Thank you, Michael. But I think it's not exactly what I am looking for. if you're looking to change the actual format stored in the column, make your own TypeDecorator which specifies the underlying format desired as the impl ( i think in this case it would be Numeric). TypeDecorator

[sqlalchemy] Re: How to bypass scoped_session?

2009-09-08 Thread King Simon-NFHD78
-Original Message- From: sqlalchemy@googlegroups.com [mailto:sqlalch...@googlegroups.com] On Behalf Of Eloff Sent: 08 September 2009 04:40 To: sqlalchemy Subject: [sqlalchemy] How to bypass scoped_session? Hi, I'm using scoped_session in my pylons app, but sometimes I have

[sqlalchemy] Cascade option, what does all mean?

2009-09-08 Thread Eloff
Hi, I see cascade='all, delete, delete-orphan' in the tutorial, but I thought I read in the docs elsewhere (can't seem to find the place atm) that all includes merge, delete, and others so that cascade='all, delete-orphan' should be equivalent? Is this correct? Thanks, -Dan

[sqlalchemy] Drop and recreate primary key indexes

2009-09-08 Thread Wolodja Wentland
Hi all, is it possible to drop primary key indexes from within SA? I already found the table.indexes set, but it does not contain the primary key index. I can therefore drop all indexes for a table except the primary key one. It seems to me as if SA relies on a strict naming scheme for primary

[sqlalchemy] Re: Cascade option, what does all mean?

2009-09-08 Thread Mike Conley
Your assumption should be correct. http://www.sqlalchemy.org/docs/05/reference/orm/mapping.html#sqlalchemy.orm.relation On Tue, Sep 8, 2009 at 6:40 AM, Eloff dan.el...@gmail.com wrote: Hi, I see cascade='all, delete, delete-orphan' in the tutorial, but I thought I read in the docs

[sqlalchemy] update table set val=val+10 where...

2009-09-08 Thread Petr B.
Hi all, I have been searching in vain on how to make something like this: UPDATE table SET value=value+10 in the expression language (not ORM). Can somebody help me please? (what I do now is I obtain a connection and call a raw sql, but that is rather ugly isn't it?) Thanks, Petr

[sqlalchemy] Re: Drop and recreate primary key indexes

2009-09-08 Thread Wolodja Wentland
On Tue, Sep 08, 2009 at 13:06 +0200, Wolodja Wentland wrote: is it possible to drop primary key indexes from within SA? I already found the table.indexes set, but it does not contain the primary key index. I can therefore drop all indexes for a table except the primary key one. I did some

[sqlalchemy] Re: Problems with NOT IN and layered subqueries

2009-09-08 Thread Michael Bayer
an example of NOT IN (subquery): from sqlalchemy import * from sqlalchemy.sql import column, table s = select([column(foo)]).select_from(table(bar)).where(~column(foo).in_(select([column(bar)]).select_from(table(bat)).where(column(bar)==5))) print s SELECT foo FROM bar WHERE foo NOT IN

[sqlalchemy] Re: How to use julianday for datetime storing with sqlite

2009-09-08 Thread Michael Bayer
Slava Tutushkin wrote: Thank you, Michael. But I think it's not exactly what I am looking for. if you're looking to change the actual format stored in the column, make your own TypeDecorator which specifies the underlying format desired as the impl ( i think in this case it would be

[sqlalchemy] Re: Drop and recreate primary key indexes

2009-09-08 Thread Michael Bayer
Wolodja Wentland wrote: On Tue, Sep 08, 2009 at 13:06 +0200, Wolodja Wentland wrote: is it possible to drop primary key indexes from within SA? I already found the table.indexes set, but it does not contain the primary key index. I can therefore drop all indexes for a table except the primary

[sqlalchemy] Re: Drop and recreate primary key indexes

2009-09-08 Thread Michael Bayer
Wolodja Wentland wrote: Hi all, is it possible to drop primary key indexes from within SA? I already found the table.indexes set, but it does not contain the primary key index. I can therefore drop all indexes for a table except the primary key one. It seems to me as if SA relies on a

[sqlalchemy] Re: How to bypass scoped_session?

2009-09-08 Thread Eloff
On Sep 8, 3:47 am, King Simon-NFHD78 simon.k...@motorola.com wrote: Automatically adding objects to a session when they are created is a feature of Session.mapper (rather than the plain orm.mapper function), and is deprecated. If you use the plain mapper function, all root objects that you

[sqlalchemy] Re: How to use julianday for datetime storing with sqlite

2009-09-08 Thread Slava Tutushkin
Thanks for the explanations! I'm going to experiment with all that. So only textual modifications to the queries are needed. Values to and from the query shall be passed as it is now, as ISO strings. as an aside, the DateTime types expect Python datetime objects, not strings.  I thought

[sqlalchemy] Re: How to use julianday for datetime storing with sqlite

2009-09-08 Thread Michael Bayer
Slava Tutushkin wrote: On Sep 8, 6:18 pm, Michael Bayer mike...@zzzcomputing.com wrote: julianday being a SQLite function ?  i.e. you'd like SQLite to do the date arithmetic from the ISO value for you ?  or you'd like your custom type to provide the julianday numeric value ? better yet,

[sqlalchemy] Re: Drop and recreate primary key indexes

2009-09-08 Thread Michael Bayer
Wolodja Wentland wrote: I can't drop these constraints as well. Even if i accept that my tables are created with primary key definitions the recipe you showed me does not work. It fails with: --- snip --- ... /sqlalchemy/sql/compiler.pyc in _requires_quotes(self, value) 1306 def

[sqlalchemy] Re: Drop and recreate primary key indexes

2009-09-08 Thread Wolodja Wentland
On Tue, Sep 08, 2009 at 13:05 -0400, Michael Bayer wrote: Alternatively, just start using SQLalchemy 0.6 (its trunk so far): from sqlalchemy.schema import DropConstraint for cons in table.constraints: if isinstance(con, PrimaryKeyConstraint): engine.execute(DropConstraint(con))

[sqlalchemy] Re: Problems with NOT IN and layered subqueries

2009-09-08 Thread Michael Bayer
Seth wrote: Thank you Michael, What about using this type of thing inside another query? I keep getting: AttributeError: 'Select' object has no attribute '_nested_statement' the identifier '_nested_statement' is not part of SQLAlchemy so that's something on your end (or perhaps you're

[sqlalchemy] Re: Problems with NOT IN and layered subqueries

2009-09-08 Thread Seth
Thank you Michael, What about using this type of thing inside another query? I keep getting: AttributeError: 'Select' object has no attribute '_nested_statement' Seth On Sep 8, 7:16 am, Michael Bayer mike...@zzzcomputing.com wrote: an example of NOT IN (subquery): from sqlalchemy

[sqlalchemy] Re: How to use julianday for datetime storing with sqlite

2009-09-08 Thread Slava Tutushkin
On Sep 8, 6:18 pm, Michael Bayer mike...@zzzcomputing.com wrote: julianday being a SQLite function ?  i.e. you'd like SQLite to do the date arithmetic from the ISO value for you ?  or you'd like your custom type to provide the julianday numeric value ? better yet, to ensure perfect clarity

[sqlalchemy] Tutorial program 'selectdemo.py'

2009-09-08 Thread drednot57
From the website http://www.rmunn.com/sqlalchemy-tutorial/tutorial.html. It's for SQLAlchemy version 0.2. I have version 0.5.5 I get an error when I execute the code: Traceback (most recent call last): File selectdemo.py, line 55, in module s = users.select(users.c.name.in_('Mary',

[sqlalchemy] Re: Drop and recreate primary key indexes

2009-09-08 Thread Wolodja Wentland
On Tue, Sep 08, 2009 at 17:35 -0400, Michael Bayer wrote: Wolodja Wentland wrote: I can't drop these constraints as well. Even if i accept that my tables are created with primary key definitions the recipe you showed me does not work. It fails with: --- snip --- ...

[sqlalchemy] Re: Tutorial program 'selectdemo.py'

2009-09-08 Thread Wolodja Wentland
On Tue, Sep 08, 2009 at 15:09 -0700, drednot57 wrote: Traceback (most recent call last): File selectdemo.py, line 55, in module s = users.select(users.c.name.in_('Mary', 'Susan')) TypeError: in_() takes exactly 2 arguments (3 given) # The in and between operations are also available s =

[sqlalchemy] Re: Help on Custom Type with TypeEngine (Oracle SDO_GEOM)

2009-09-08 Thread Jarrod Chesney
Sounds like you are working with Intergraph GIS, Is that correct? On Sep 8, 7:32 pm, Nicolas Dufrane dufrane.nico...@gmail.com wrote: thanks for this complete answer ! I will investigate a little more in existing projects like geoalchemy, mapfish to find a nice way to implement oracle

[sqlalchemy] Re: Drop and recreate primary key indexes

2009-09-08 Thread Michael Bayer
On Sep 8, 2009, at 7:01 PM, Wolodja Wentland wrote: Any tips on how to dynamically create *Constraints? The inline_ddl idea does not work and doing something like: how about engine.execute(drop constraint pkey_%s % table.name) ? since PG is using a naming scheme for primary key

[sqlalchemy] Re: Problems with NOT IN and layered subqueries

2009-09-08 Thread Michael Bayer
why dont you try: query(Post.id, Post.user_id).from_statement(statement1.union (statement2)) ? On Sep 8, 2009, at 8:27 PM, Seth wrote: Michael, I was using SA 0.5.1. Upgrading to 0.5.5 resolved the AttributeError. I am, however, having one final issue with my query: users =

[sqlalchemy] Re: Problems with NOT IN and layered subqueries

2009-09-08 Thread Seth
Michael, I was using SA 0.5.1. Upgrading to 0.5.5 resolved the AttributeError. I am, however, having one final issue with my query: users = DBSession.query(Post.id.label('post_id'), Post.user_id.label('user_id')).union(Discussion.__table__.select().with_only_columns(['post_id',

[sqlalchemy] Re: Optimal table design for SQLAlchemy (Or One-to-many tables vs meta tables)

2009-09-08 Thread Paul Nesbit
Hi Michael, Thanks for taking the time to provide this informative and helpful reply, it's much appreciated. Cheers, Paul On Mon, Sep 7, 2009 at 4:08 PM, Michael Bayer mike...@zzzcomputing.comwrote: On Sep 7, 2009, at 3:27 PM, Paul Nesbit wrote: Hi, I'm in the process of setting up