On Sunday, June 3, 2018 at 7:17:55 PM UTC-7, rvd wrote: > > Hi all, > > I am writing a Flask API that needs to communicate with many datastores, > Postgres on AWS RDS being one of them. I want to avoid Flask-SQLAlchemy > (trying to reduce package dependence); I think the standard SQLAlchemy > library should suffice. I have described the issue thoroughly here > <https://stackoverflow.com/questions/50669231/sqlalchemy-sessions-keep-dropping-after-a-few-minutes> > (code > is here as well). But here is the synopsis. When I use a Session object > in my app, for the first few requests, it works great. Then, if I wait for > a while and fire off another request, I get a Psycopg2 error about the > server closing off the connection unexpectedly. This is rather crippling. > I have spent a lot of time going through SO, asked in the SQLAlchemy IRC > channel, and tried many tutorials, and this seems to be a standard valid > pattern, so I am not sure what is going wrong. Should I not be removing the > session? Should I be using the @app.teardown_appcontext decorator (it > seems that if I just remove the sessions myself as I am doing now, I > shouldn't have to)? Should I be using a connection pool instead (it seems > that QueuePool is enabled under the hood by default anyway)? If it helps, > I am using the latest version of all packages, Python 3.6.5, and Postman to > send the requests to the server, which is running at localhost:5000. Any > advice would be much appreciated - thanks in advance! > > Best, > rvd >
-- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
