[sqlalchemy] Mapping a Class against Multiple Tables - how to define relationship

2011-11-13 Thread Yap Sok Ann
Using the second example in http://www.sqlalchemy.org/docs/orm/mapper_config.html#mapping-a-class-against-multiple-tables, how should I define relationship properties KeywordUser.keyword and KeywordUser.user? I tried different primaryjoin's, but when used as filter, e.g.

[sqlalchemy] Properly handling sessions in rollback

2011-11-13 Thread Vlad K.
Hi. Imagine the following scenario: session = DBSession() readonly_model = session.query(ReadOnlyModel).get(id) # Readonly means the model will NOT have its data changed in the life of the transaction(s). method_one(readonly_model.readonly_data, param_1, param_2, ...)

Re: [sqlalchemy] Properly handling sessions in rollback

2011-11-13 Thread Michael Bayer
On Nov 13, 2011, at 7:59 AM, Vlad K. wrote: Hi. Imagine the following scenario: session = DBSession() readonly_model = session.query(ReadOnlyModel).get(id) # Readonly means the model will NOT have its data changed in the life of the transaction(s).

Re: [sqlalchemy] Properly handling sessions in rollback

2011-11-13 Thread Vlad K.
Hi, thanks for your reply. On 11/13/2011 05:15 PM, Michael Bayer wrote: From what I've read in the docs, I am supposed to do session.refresh(), No that's not required at all. All the objects that are still referenced outside the session, stay present in the session and will reload

[sqlalchemy] Re: can't get delete-orphan work

2011-11-13 Thread sector119
Thanks a lot, Michael! -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/Vc5LM46bOiUJ. To post to this group, send email to sqlalchemy@googlegroups.com. To

Re: [sqlalchemy] Properly handling sessions in rollback

2011-11-13 Thread Michael Bayer
On Nov 13, 2011, at 11:52 AM, Vlad K. wrote: Hi, thanks for your reply. On 11/13/2011 05:15 PM, Michael Bayer wrote: From what I've read in the docs, I am supposed to do session.refresh(), No that's not required at all. All the objects that are still referenced outside the

Re: [sqlalchemy] Properly handling sessions in rollback

2011-11-13 Thread Vlad K.
On 11/13/2011 06:16 PM, Michael Bayer wrote: But they're not, I'm getting Instance XY is not present in this Session, for readonly_model when method_two is called, if there was a rollback in method_one. That would indicate you add()-ed it during the transaction. Any data that was created

Re: [sqlalchemy] Properly handling sessions in rollback

2011-11-13 Thread Michael Bayer
On Nov 13, 2011, at 12:51 PM, Vlad K. wrote: I suppose it interacts with http://pypi.python.org/pypi/zope.sqlalchemy oh duh yes I can't keep it straight. Vlad -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this

[sqlalchemy] order of the columns in table.__table__.columns._all_cols

2011-11-13 Thread Hanss
Hello, I'm trying to get the name of the columns of my tables, writing columnDb = self.table.__table__.columns._all_cols self.labels = [col.name for col in columnDb] ColumnDb is a Set Type... and it usually returns all the columns in the same order defined in the table...but not always.

Re: [sqlalchemy] order of the columns in table.__table__.columns._all_cols

2011-11-13 Thread Michael Bayer
On Nov 13, 2011, at 8:29 PM, Hanss wrote: Hello, I'm trying to get the name of the columns of my tables, writing columnDb = self.table.__table__.columns._all_cols self.labels = [col.name for col in columnDb] ColumnDb is a Set Type... and it usually returns all the columns in

[sqlalchemy] What's the common practice to represent data like account status ('active', 'inactive', etc,..)

2011-11-13 Thread espresso maker
Here are few columns that I am not sure how to represent their data in the database. Columns like 'status' in account indicating the account status. Columns like 'type' indicating the account type 'business', individual', 'reseller'. Granted I can normalize them and create tables for each. but

Re: [sqlalchemy] What's the common practice to represent data like account status ('active', 'inactive', etc,..)

2011-11-13 Thread Michael Bayer
On Nov 13, 2011, at 11:51 PM, espresso maker wrote: Here are few columns that I am not sure how to represent their data in the database. Columns like 'status' in account indicating the account status. Columns like 'type' indicating the account type 'business', individual', 'reseller'.

[sqlalchemy] Re: order of the columns in table.__table__.columns._all_cols

2011-11-13 Thread Hanss
On 14 Nov, 03:19, Michael Bayer mike...@zzzcomputing.com wrote: When using Declarative, the order ultimately comes from the order in which each Column object was generated, which drives the order in which Declarative adds them to the Table which is then what you get when you iterate over

[sqlalchemy] Re: What's the common practice to represent data like account status ('active', 'inactive', etc,..)

2011-11-13 Thread espresso maker
Thanks this is exactly what I was looking for! :) On Nov 13, 9:25 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Nov 13, 2011, at 11:51 PM, espresso maker wrote: Here are few columns that I am not sure how to represent their data in the database. Columns like 'status' in