I have used postgresql with SQLAlchemy without issue but am trying to get at database that's in Azure running on SQL Server. I am unable to connect and can't really figure out why. I have searched quite a bit and have come across most articles pointing me towards using the create_engine but I can't seem to get that to work with using ORM. Here is my current code:
EXCEPTION
sqlalchemy.exc.NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:sqlserver
from flask import Flask
from models import db, People
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlserver://<connectionString>'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
db.init_app(app)
@app.route('/')
def hello_world():
#Exception here
people = People.query.filter_by(birthYear=12).all()
return 'Hello World!'
if __name__ == '__main__':
app.run()
Azure offers me 4 different connection strings:
- ADO.NET
- JDBC
- ODBC
- PHP (not an option for me since i'm not using PHP)
Is there any way to make SQLAlchemy work with SQL Server?