Seemingly, when Heroku said 99.5% uptime for postgres, they meant it. The issue with this is that even though we're statistically unlikely to actually feel the direct effects of the downtime (~20 minutes per month), closing the database disconnects psycopg2.
The solution is to wrap the connection class and modify the cursor function to something that will check for an issue and reconnect if needed.
Seemingly, when Heroku said 99.5% uptime for postgres, they meant it. The issue with this is that even though we're statistically unlikely to actually feel the direct effects of the downtime (~20 minutes per month), closing the database disconnects psycopg2.
The solution is to wrap the connection class and modify the cursor function to something that will check for an issue and reconnect if needed.