to catch the exceptions from a module, you should import it.... import psycopg2
in your controller will let you do: try: db(db.table2.id>0).delete() except psycopg2.IntegrityError: session.flash = "can't do this and that" However, instead of resorting to catch the integrityerror that in the future may change, I'd go with the route that sees if in the child table(s) there are records attached. --