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:
>
> try:
>     MyDBLog(
>         myfield='A too long string xxxxxxxxxxxx'
>     )
> except Exception, e:
>     log.error("Exception occurred with database logging: %s" % e)
>
>
> Unfortunately, 'myfield' is (for example) a string of only length 10,
> so the session fails with
>     ProgrammingError: (ProgrammingError) value too long for type
> character varying(10)
>
> This error occurs at session commit time, so my 'except' clause above
> is useless.
>
> As 'MyDBLog' is not critical, I want to be able to ignore/log any kind
> of Exception which the 'try' block above ultimately generates.  Is
> there a way to do this?
>
> Thanks!
>
> Eoghan
> >
>
>   


-- 
David Gardner
Pipeline Tools Programmer, "Sid the Science Kid"
Jim Henson Creature Shop
(323) 802-1717 [EMAIL PROTECTED]



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to