'Flask error: sqlalchemy.exc.NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:mongodb
I am basically trying to integrate my mlab database with my flask app and I keep getting the error
sqlalchemy.exc.NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:mongodb
I tested the mlab database already using the mongo shell and it worked fine but some reason the app has a problem acessing it
from flask import Flask, render_template, request
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
#tells srl alchemy how to connect to our database
app.config['SQLALCHEMY_DATABASE_URI']='mongodb://xxxxx:[email protected]:11103/namebase'
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"]= False
db=SQLAlchemy(app)
class Comment(db.Model):
id=db.Column(db.Integer,primary_key=True)
name=db.Column(db.String(20))
column=db.Column(db.String(200))
@app.route('/')
def index():
return render_template('index.html')
@app.route('/sign')
def sign():
return render_template('sign.html')
@app.route("/process",methods=["POST"])
def process():
name=request.form["name"]
comment=request.form['comment']
return render_template("index.html",
name=name,comment=comment
)
if __name__ == '__main__':
app.run(debug=True)
Solution 1:[1]
You can use the CData Python Connector to use mongodb with sqlalchemy: https://www.cdata.com/kb/tech/mongodb-python-sqlalchemy.rst
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ishefi |
