nxy/bot
jkhsjdhjs e03f5d0a43 add auto reconnect for postgres
This only works on the second database interaction, since psycopg2 only notices that
the connection is gone, when a query is executed.

So in the common case reconnect works as follows:
- some bot method calls a cursor function like .execute(), .fetchone(), etc.
  - this raises an error if the connection is broken
  - if following code then requests a new cursor, this will also fail since psycopg2
    now knows that the connection is gone
  - the error is caught in storage.DBConn.cursor(), a new connection will be set up
    of which a new cursor is yielded
If the error happens in connection.commit() or .rollback() instead we can instantly
reconnect since these methods are wrapped.

So why not wrap the cursor methods as well?
Consider the following example:
A query is the last thing that was executed on a cursor.
The database connection is lost.
Now .fetchone() is called on the cursor.
We could wrap .fetchone() and reconnect, but we'd have to use a new cursor since
cursors are linked to connections. And on this new cursor .fetchone() wouldn't
make any sense, since we haven't executed a query on this cursor.
2020-03-16 21:51:32 +00:00
..
__init__.py add auto reconnect for postgres 2020-03-16 21:51:32 +00:00
__main__.py Huge cleanup and refactoring :> 2017-08-22 17:43:48 +02:00
admin.py remove +R, add +B on connect 2018-12-10 16:04:59 +00:00
ascii.py add a lot of useless and ascii commands 2018-08-14 01:07:57 +02:00
coins.py Set 'currency' to 'usd' if fallback has been used 2017-10-15 04:03:30 +02:00
ctcp.py Huge cleanup and refactoring :> 2017-08-22 17:43:48 +02:00
drugs.py Added .meth command 2017-09-06 13:06:21 +02:00
isup.py Huge cleanup and refactoring :> 2017-08-22 17:43:48 +02:00
linux.py add flash to REE regex 2019-09-19 19:24:06 +00:00
mcmaniac.py add auto reconnect for postgres 2020-03-16 21:51:32 +00:00
quotes.py add auto reconnect for postgres 2020-03-16 21:51:32 +00:00
rape.py add auto reconnect for postgres 2020-03-16 21:51:32 +00:00
regex.py add auto reconnect for postgres 2020-03-16 21:51:32 +00:00
seen.py add auto reconnect for postgres 2020-03-16 21:51:32 +00:00
storage.py add auto reconnect for postgres 2020-03-16 21:51:32 +00:00
tell.py add auto reconnect for postgres 2020-03-16 21:51:32 +00:00
timer.py add auto reconnect for postgres 2020-03-16 21:51:32 +00:00
urban.py Huge cleanup and refactoring :> 2017-08-22 17:43:48 +02:00
useless.py add auto reconnect for postgres 2020-03-16 21:51:32 +00:00
utils.py quotes: add quote searching 2019-12-08 19:35:10 +00:00
weather.py Huge cleanup and refactoring :> 2017-08-22 17:43:48 +02:00
youtube.py Huge cleanup and refactoring :> 2017-08-22 17:43:48 +02:00