Error handling in SQLAlchemy

3,129 views
Skip to first unread message

Boda Cydo

unread,
Jan 25, 2010, 8:52:58 PM1/25/10
to sqlalchemy
Hello all!

I have a question about handling errors in SQLAlchemy.

Before I used SQLAlchemy I used to rigorously check for all errors
when executing queries, like:

> status = db.query("INSERT INTO users ...")
> if !status:
> handle_insert_error()

But now when I have switched to SQLAlchemy I write code with no error
checking whatsoever, like:

> user = User("Boda Cydo")
> session.add(user)
> session.commit()

And I do absolutely no error checking. I absolutely feel horrible for
writing such code.

I talked in #sqlalchemy and someone told me that SQLAlchemy throws
exceptions on errors. That's better. But where is it documented? The
person couldn't find anything. Neither could I.

Can anyone please help with tips (or point me to documentation) about
what exceptions get raised when?

I absolutely don't want to write code without error handling.


Thanks,
Boda Cydo

Boda Cydo

unread,
Jan 26, 2010, 8:04:57 AM1/26/10
to sqlalchemy


I asked it on Stackoverflow and got a great answer!

Here it is: http://stackoverflow.com/questions/2136739/error-handling-in-sqlalchemy


Boda Cydo

Reply all
Reply to author
Forward
0 new messages