'raise exc.NoSuchModuleError( sqlalchemy.exc.NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:postgresql
I created a sample flask application, I want to connect PostgreSQL database to my project. I installed flask_sqlalchemy.
here is my Code
from flask import Flask, url_for, render_template
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://michealscott:dwight@localhost:5432/michealscott'
db = SQLAlchemy(app)
class User(db.Model):
__tablename__ = 'books'
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(80), unique=True)
email = db.Column(db.String(120), unique=True)
def __init__(self, username, email):
self.username = username
self.email = email
@app.route('/')
def hello_world():
return render_template("index.html")
I cd-ed into my src directory and executed:
python
>> from app import db
>> db.create_all()
then the above error shows up.
After searching over internet. I also did
pip install psycopg2
still no luck.
there is a same question on stack overflow and couple of answers/suggestions. I was not able to comment on the post so asking it again pardon me!
Please help.
Thank you in advance.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|