Re: [sqlalchemy] More autocommit and exception-handling questions

2011-03-01 Thread Michael Bayer
On Mar 1, 2011, at 1:42 AM, Romy wrote: Getting some conflicting advice on autocommit and wrapping the request in a try/except block on the Tornado mailing list, was wondering what your thoughts are on the issues brought up in the following message and its replies:

[sqlalchemy] Setting column value that changes everyday

2011-03-01 Thread dalia
Hi, I have a table of phone numbers which has 3 columns named - 1. ph_no Integer not null 2. last_contacted Datetime not null 3. expiry_code Text() The behaviour of the table should be - When the last_contacted column has a date which is 3 months older, the expiry_code column should have the

[sqlalchemy] Re: Setting column value that changes everyday

2011-03-01 Thread GHZ
Hi, Do you need to store expiry_code? seeing as it is a function of last_con and the current date. class PhNumber(Base): __tablename__ = 'ph_numbers' ph_no = Column(Integer, nullable=False) last_con = Column(DateTime, nullable=False) @property def expiry_code(self): msg = 'Expired

[sqlalchemy] Query a value that is a relationship

2011-03-01 Thread Hector Blanco
Hello everyone: Let's say I have a class User and a class UserGroup. One user can belong to one userGroup, an a userGroup can contain several users (pretty typical structure). It's a simple relationship I got modeled like: class UserGroup(declarativeBase): Represents a group of users

[sqlalchemy] multiple inheritance simplified case

2011-03-01 Thread farcat
Hi, I have been reading the posts on implementing multiple inheritance in SA. I have a question, for a slightly simpler method of MI, where there is no overriding of attributes (and e.g. therefore no diamond problem). This would mean that all underlying tables for classes could contain columns

[sqlalchemy] Re: Query a value that is a relationship

2011-03-01 Thread Hector Blanco
Hello everyone: Let's say I have a class User and a class UserGroup. One user can belong to one userGroup, an a userGroup can contain several users (pretty typical structure). It's a simple relationship I got modeled like: class UserGroup(declarativeBase): Represents a group of users

Re: [sqlalchemy] multiple inheritance simplified case

2011-03-01 Thread Michael Bayer
On Mar 1, 2011, at 5:42 PM, farcat wrote: Hi, I have been reading the posts on implementing multiple inheritance in SA. I have a question, for a slightly simpler method of MI, where there is no overriding of attributes (and e.g. therefore no diamond problem). This would mean that all

Re: [sqlalchemy] Re: Query a value that is a relationship

2011-03-01 Thread Michael Bayer
On Mar 1, 2011, at 5:50 PM, Hector Blanco wrote: Hello everyone: Let's say I have a class User and a class UserGroup. One user can belong to one userGroup, an a userGroup can contain several users (pretty typical structure). It's a simple relationship I got modeled like: class

[sqlalchemy] Re: Setting column value that changes everyday

2011-03-01 Thread Sergey V.
Do you need to store expiry_code? seeing as it is a function of last_con and the current date. Second that. I would also point out that phone number probably shouldn't be an integer - how would you store phone numbers which start with 0, for example? I'd rather make it a String. -- You

[sqlalchemy] SQL to sqlalchemy help

2011-03-01 Thread eddy
Hi All, I have been trying to covert this sql query to sqlalchemy one for hours now with no luck. any help will be appreciated update table1 set columnValue=(case when columnValue=A then B when columnValue=B then A end) where columnValue in (A,B); It is just swapping the columnValue where its

Re: [sqlalchemy] SQL to sqlalchemy help

2011-03-01 Thread Michael Bayer
On Mar 1, 2011, at 9:14 PM, eddy wrote: Hi All, I have been trying to covert this sql query to sqlalchemy one for hours now with no luck. any help will be appreciated update table1 set columnValue=(case when columnValue=A then B when columnValue=B then A end) where columnValue in

[sqlalchemy] Re: More autocommit and exception-handling questions

2011-03-01 Thread Romy
On Mar 1, 2:29 am, Michael Bayer mike...@zzzcomputing.com wrote: On Mar 1, 2011, at 1:42 AM, Romy wrote: Getting some conflicting advice on autocommit and wrapping the request in a try/except block on the Tornado mailing list, was wondering what your thoughts are on the issues brought up