catching SQLAlchemy exceptions

To catch any exception SQLAlchemy throws:

from sqlalchemy import exc
db.add(user)
try:
  db.commit()
except exc.SQLAlchemyError:
  pass # do something intelligent here

See help(sqlalchemy.exc) and help(sqlalchemy.orm.exc) for a list of possible exceptions that sqlalchemy can raise.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)