Am 29.11.2017 um 17:16 schrieb Mike Bayer:
> 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.
Of course, In my case it will be a call from the crontab starting my
process regularly, I just wanted my process not to exit without writing
it to the logfile what the problem was with a "nicely" formatted
message, so the logfiles can be checked for certain messages in ELK. So
I think I can limit them down to if there is an error connecting to the
database because the queries are pretty much fixed and only differ in
which element(s) I query and of course I have to make sure that the
configuration is correct.
>
>
>
>
>> 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.
Thank you very much, I must have not seen the Link.
>>
>>> 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.

-- 
Karlsruher Institut für Technologie (KIT)
Steinbuch Centre für Computing (SCC)

B.Sc. Lars Liedtke
Administrator bwSync&Share

Hermann-von-Helmholtz-Platz 1
Gebaäude 441/Raum 233
D-76344 Eggenstein-Leopoldshafen

Telefon: +49 721 608-28875
Fax: +49 721 608-24972
E-Mail: Lars.Liedtke∂kit.edu
Web: www.scc.kit.edu  

KIT – Die Forschungsuniversität in der Helmholtz-Gemeinschaft

Das KIT ist seit 2010 als familiengerechte Hochschule zertifiziert.


-- 
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.

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to