[sqlalchemy] lockmode-SA-error

2010-05-26 Thread dhanil anupurath
Hi I am using oracle/mysql and sqlalchemy for a project I am working on. I have a query executed like this SELECT table_entity_id, table_entity_type, table_avail_state, table_monit_state, table_transient_state, table_transient__1, table_owner, table_timestamp, table_description FROM (SELECT

[sqlalchemy] SA-Lockmode-oracle

2010-05-26 Thread dhanil anupurath
Hi I am using oracle/mysql and sqlalchemy for a project I am working on. I am using lockmode in SA query,while generating an ORACLE query it causes trouble. The class definition is like this: class AvailState(Base): MONITORING = 1 NOT_MONITORING = 0 __tablename__ = 'avail_current'

[sqlalchemy] Acting on creation of model instances

2010-05-26 Thread Dan Ellis
I've only found partial answers to this problem so far, so I'd like to expand on it here. I have a site in which users post stories, and their friends are notified. In order to decouple different parts of the business logic, I would like to use a publish/subscribe mechanism that raises an event

Re: [sqlalchemy] Acting on creation of model instances

2010-05-26 Thread Michael Bayer
On May 26, 2010, at 12:18 AM, Dan Ellis wrote: class EventExtension(SessionExtension): def __init__(self): self.new = [] def after_flush(self, session, flush_context): self.new = session.new return EXT_CONTINUE def after_commit(self, session):

Re: [sqlalchemy] SA-Lockmode-oracle

2010-05-26 Thread Michael Bayer
On May 26, 2010, at 9:16 AM, dhanil anupurath wrote: Hi I am using oracle/mysql and sqlalchemy for a project I am working on. I am using lockmode in SA query,while generating an ORACLE query it causes trouble. The class definition is like this: class AvailState(Base):

Re: [sqlalchemy] SA-Lockmode-oracle

2010-05-26 Thread dhanil anupurath
Hi, Thanks for the quick reply. In my query i am not using any limit()/offset()/first() but i am using order by ascending. can order by cause an issue?? avail_states=DBSession.query( AvailState).with_lockmode('update').\ filter(AvailState.entity_id.in_(input_entityids)).\

[sqlalchemy] complex in clause

2010-05-26 Thread Glauco Uri
What is the best practice for this case? select * from my_tbl where (a,b) in ((1,1),(2,2)) It seems to me that in clause is a column attribute so i don't figure how to sqlalchemyfy this where condition Thank you in advance Gla -- Glauco Uri Prometeia SpA Via G. Marconi, 43 - 40122

Re: [sqlalchemy] SA-Lockmode-oracle

2010-05-26 Thread Michael Bayer
On May 26, 2010, at 10:10 AM, dhanil anupurath wrote: Hi, Thanks for the quick reply. In my query i am not using any limit()/offset()/first() but i am using order by ascending. can order by cause an issue?? your stacktrace says you are using first(): Traceback (most recent call last):

Re: [sqlalchemy] complex in clause

2010-05-26 Thread Michael Bayer
search the docs for tuple_. On May 26, 2010, at 10:35 AM, Glauco Uri wrote: What is the best practice for this case? select * from my_tbl where (a,b) in ((1,1),(2,2)) It seems to me that in clause is a column attribute so i don't figure how to sqlalchemyfy this where condition

[sqlalchemy] scoped_session in a single threaded environment?

2010-05-26 Thread Chris Withers
Hi all, Is there any harm in using scoped_session in a single threaded environment? cheers, Chris -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group,

[sqlalchemy] Hierarchical queries with pgsql = 8.4.0

2010-05-26 Thread Mariano Mara
Hi everyone. I have been working in a little class that brings support for with recursive idiom in my project. Actually the part it supports for the moment are the necessary bits to generate hierarchical data (I thought somebody might find it useful too so I added it as a recipe in the wiki[1]).

Re: [sqlalchemy] Hierarchical queries with pgsql = 8.4.0

2010-05-26 Thread Michael Bayer
On May 26, 2010, at 11:47 AM, Mariano Mara wrote: Hi everyone. I have been working in a little class that brings support for with recursive idiom in my project. Actually the part it supports for the moment are the necessary bits to generate hierarchical data (I thought somebody might find

Re: [sqlalchemy] Hierarchical queries with pgsql = 8.4.0

2010-05-26 Thread Mariano Mara
Excerpts from Michael Bayer's message of Wed May 26 13:23:01 -0300 2010: On May 26, 2010, at 11:47 AM, Mariano Mara wrote: Hi everyone. I have been working in a little class that brings support for with recursive idiom in my project. Actually the part it supports for the moment are the

[sqlalchemy] Re: Acting on creation of model instances

2010-05-26 Thread Dan Ellis
On May 26, 9:43 am, Michael Bayer mike...@zzzcomputing.com wrote: You can expire the attribute manually ahead of time if you want it to reload its value (should be fine within after_commit). No, it seems that in after_commit the newly added instance is not yet in session.identity_map, so

[sqlalchemy] innerjoin and eagerloading

2010-05-26 Thread David Gardner
I have a users table, with a lazy=False, innerjoin=True relation to the preferences table (these could probably be the same table but they are separate for historical reasons). One of the gotchas that I am running into is when I do an outerjoin on to the user's table, it effectively becomes

Re: [sqlalchemy] Re: Acting on creation of model instances

2010-05-26 Thread Michael Bayer
On May 26, 2010, at 1:33 PM, Dan Ellis wrote: On May 26, 9:43 am, Michael Bayer mike...@zzzcomputing.com wrote: You can expire the attribute manually ahead of time if you want it to reload its value (should be fine within after_commit). No, it seems that in after_commit the newly added

Re: [sqlalchemy] innerjoin and eagerloading

2010-05-26 Thread Michael Bayer
On May 26, 2010, at 1:39 PM, David Gardner wrote: I have a users table, with a lazy=False, innerjoin=True relation to the preferences table (these could probably be the same table but they are separate for historical reasons). One of the gotchas that I am running into is when I do an

[sqlalchemy] Roundin' up the children!

2010-05-26 Thread ObjectEvolution
Hi, I've got the following tables in my app (only showing applicable columns here) storing categories for my app: Base - id (int) PK - deleted (int) - 0/1 as a value Category - id (int) PK/FK - refers to Base.id - parent_id (int) FK - self-referential to Category.id I then have a Category

Re: [sqlalchemy] Roundin' up the children!

2010-05-26 Thread Michael Bayer
On May 26, 2010, at 4:56 PM, ObjectEvolution wrote: Hi, I've got the following tables in my app (only showing applicable columns here) storing categories for my app: Base - id (int) PK - deleted (int) - 0/1 as a value Category - id (int) PK/FK - refers to Base.id - parent_id (int)

[sqlalchemy] Re: Roundin' up the children!

2010-05-26 Thread ObjectEvolution
Thanks for the input Michael. I think the polymorphism is messing things up...just a hunch. Your suggestion didn't work but this ended up working: 'children': relation(Category, primaryjoin=and_(TABLES.CATEGORY.c.id==TABLES.CATEGORY.c.parent_id, TABLES.BASE.c.deleted==False),

[sqlalchemy] Use a foreign key mapping to get data from the other table using Python and SQLAlchemy.

2010-05-26 Thread Az
Basically, I've got these simple classes mapped to tables, using SQLAlchemy. I know they're missing a few items but those aren't essential for highlighting the problem. class Customer(object): def __init__(self, uid, name, email): self.uid = uid self.name =