[sqlalchemy] Re: ProgrammingError and Catching an Exception

2008-09-12 Thread Eoghan Murray
As the session is handled by TurboGears, I tried the following: from turbogears.database import session try: MyDBLog( myfield='A too long string ' ) session.commit() session.begin() except Exception, e: log.error(Exception occurred with database logging:

[sqlalchemy] Re: ProgrammingError and Catching an Exception

2008-09-11 Thread Barry Hart
I don't know of a way to do what you're asking. However, you could simply create your own constructor for MyDBLog which truncates the string if it is too long. Barry - Original Message From: Eoghan Murray [EMAIL PROTECTED] To: sqlalchemy sqlalchemy@googlegroups.com Sent: Thursday,

[sqlalchemy] Re: ProgrammingError and Catching an Exception

2008-09-11 Thread David Gardner
Depending on how your code is layed out you could wrap your session.flush() with a try:/catch I do something like this: session.begin() try: ... session.flush() session.commit() except: session.rollback() Eoghan Murray wrote: Hi, I've the following which generates an insert:

[sqlalchemy] Re: ProgrammingError and Catching an Exception

2008-09-11 Thread David Gardner
I should mention that in my case, my sessions are non-autoflush, and non-transactional, so I do my begin()/commits() explicitly. David Gardner wrote: Depending on how your code is layed out you could wrap your session.flush() with a try:/catch I do something like this: session.begin() try: