Получаю вот такую ошибку:(psycopg2.OperationalError)
(Background on this error at: https://sqlalche.me/e/20/e3q8)
psycopg2.OperationalError:
The above exception was the direct cause of the following exception:
File "C:\Users\adfaf\Desktop\accountParser\main.py", line 125, in <module>
db.create_all()
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError)
(Background on this error at: https://sqlalche.me/e/20/e3q8)
Код:
from flask import Flask
from flask_admin import Admin
from flask_admin.contrib.sqla import ModelView
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config['FLASK_ENV'] = 'development'
app.config['SQLALCHEMY_DATABASE_URI'] = "postgresql://username:password@localhost/account"
app.config['SECRET_KEY'] = 'asd'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
db = SQLAlchemy(app)
@app.route("/", methods = ['POST'])
def mainPage():
return "hello"
class Accounts(db.Model):
__tablename__ = "accounts"
id = db.Column(db.Integer, primary_key=True)
api_key = db.Column(db.Text(60))
search_engine_id = db.Column(db.Text(60))
admin = Admin(app, name="ADMIN", template_mode="bootstrap3")
admin.add_view(ModelView(Accounts, db.session, name="Аккаунты"))
if __name__ == "__main__":
with app.app_context():
db.create_all()
app.run(debug=True)