I am building a flask project for internal use at my company. I start by using flask and postgre and used sqlalchemy and set up that connection using the model formats like below:
app = Flask(__name__)
app.config.from_object('config')
db = SQLAlchemy(app)
and that worked well. Now for security reasons we are switching to using Microsoft SQL Server with window authentication on an IIS server but i am having a lot of trouble connecting. I changed the database URI to
SQLALCHEMY_DATABASE_URI = "mssql+pyodbc://server/database"
I've checked the SQL Sever configuration and I am pretty sure that is correct. However I get the error
psycopg2.OperationalError: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
I have researched this issue and have used the pool_pre_ping solution but I get the same error (shown below)
SQLALCHEMY_ENGINE_OPTIONS = {"pool_pre_ping": True}
I have seen a lot of answers around this stuff that use the sqlalchemy.engine stuff but if possible I was hoping to use all of the db.models I have already written out but if that's not possible I can rewrite some stuff. Any help appreciated.