On Wed, Nov 29, 2017 at 11:12 AM, Mike Bayer <mike...@zzzcomputing.com> wrote:
> On Wed, Nov 29, 2017 at 3:37 AM,  <lars.lied...@kit.edu> wrote:
>> Hello everybody,
>>
>> I am writing some piece of code, which should not exit unforseen in the best
>> case, at least it should write to a log file what went wrong (e.g. Database
>> not reachable, etc). So I tried figuring out, which Exceptions would be
>> possibly thrown by SQLAlchemy:

let me also add that if "unforseen exit" is the issue, you're mostly
going to look for the SQL-related errors thrown by the driver which on
the SQLAlchemy side are the DBAPIError classes, however even in that
case, some of those errors mean "couldn't connect to the database",
which could be mis-configuration OR the database is down, others can
mean "SQL is wrong".   So even then it's hard to know ahead of time
what conditions can be caught and handled vs. which ones mean the
program needs to be re-configured and restarted.




>
> the exception classes are documented at:
>
> http://docs.sqlalchemy.org/en/latest/core/exceptions.html
> http://docs.sqlalchemy.org/en/latest/orm/exceptions.html
>
> i will note that while the ORM exceptions are linked from the front
> page of the docs, the Core ones are not, you need to go into the full
> table of contents to see it
> (http://docs.sqlalchemy.org/en/latest/contents.html).
>
> as to the exact codepath that can raise these, it depends on the
> exception.   The docstrings for the exceptions themselves can of
> course have some additional detail as to what kinds of operations
> might raise them.    Though generic ones like "InvalidRequestError" or
> "ArgumentError" are thrown in dozens of places wherever the library is
> asked to do something that doesn't make sense or function arguments
> that don't make sense are detected.
>
>>
>> The first thing I did was googling for how to find out which Exceptions
>> could be thrown in Python. The answers I found on Stack Overflow etc. were
>> like "You simply don't", "This is Python, dumbass, you can't predict which
>> are thrown so don't even try" or "Just write tests until you found them all"
>> and "Just catch the general Exception class."
>> So I tried looking at the SQLAlchemy Documentation to see if there is
>> something written about when something goes wrong, but still no luck.
>> Before I started digging into the code I thought I'd ask here first
>>
>> So is there any hint to know which Exceptions could be thrown by SQLAlchemy?
>> The error cases I could think of were mostly wrrors while connecting to the
>> database or having errors in queries. I would totally be willing to help
>> with documenting at a certain point but even for this I need to know if I
>> just did't find any documentation for this and if you consider this as
>> neccessary. I feel that it is neccessary for me not just to kill the process
>> with maybe a stack trace on stdout.
>>
>>
>> Cheers
>>
>> Lars Liedtke
>>
>> --
>> SQLAlchemy -
>> The Python SQL Toolkit and Object Relational Mapper
>>
>> http://www.sqlalchemy.org/
>>
>> To post example code, please provide an MCVE: Minimal, Complete, and
>> Verifiable Example. See http://stackoverflow.com/help/mcve for a full
>> description.
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "sqlalchemy" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to sqlalchemy+unsubscr...@googlegroups.com.
>> To post to this group, send email to sqlalchemy@googlegroups.com.
>> Visit this group at https://groups.google.com/group/sqlalchemy.
>> For more options, visit https://groups.google.com/d/optout.

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to