Connect to MSSQL Database using Flask-SQLAlchemy

前端 未结 6 530
天涯浪人
天涯浪人 2020-12-09 05:02

I\'m trying to connect to a local MSSQL DB through Flask-SQLAlchemy.

Here\'s a code excerpt from my __init__.py file:

from flask import          


        
6条回答
  •  抹茶落季
    2020-12-09 05:23

    I believe your connection string is missing the authentication details. From Flask-SQLAlchemy documentation, the connection string should have the following format

    dialect+driver://username:password@host:port/database
    

    From your example, I believe it will look something like this

    app.config['SQLALCHEMY_DATABASE_URI'] = 'mssql+pyodbc://:@:/LendApp'
    

提交回复
热议问题