ken.riel wrote: >Hello, > >I have a problem catching a sqlalchemy error in a try and expect. > >You see in the model that my user_name must be unique. So if the is a >user_name like "Ken" and i fill in my form the name "Ken" for user_name >i will get an error like this: > >SQLError: (IntegrityError) column user_name is not unique > >So i like to catch the SQLError in the expect. > >Model code: >users_table = Table ('users', metadata, > Column('user_id', Integer, primary_key=True), > Column('user_name', Unicode(16), unique=True), > Column('user_lastname', Unicode(255)), > Column('user_zipcode', Unicode(6)), > Column('display_name', Unicode(255),), > Column('password', Unicode(40)), > Column('created', Date, default=date.today) >) > >class Users(object): > pass > >assign_mapper(session.context, Users, users_table) > >Controller code: >@expose() >def drop_user(self, user_id=None, name="", last_name="", zipcode="", >password="", msg=""): > try: > user = Users() > user.user_name = 'Ken' > > session.save(user) > session.flush() > except Exception, e: > turbogears.flash(e) > return dict() > >It's not working so can anyone tel me what to do. > >Greets, >Ken van Riel > > > hi ken,
This is a tg problem. I posted a similar problem to turbogears mailing-list. Please check for answers to the subject: "sqlalchemy transaction" jo --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---