我有一个flask应用程序连接到postgres db,但是当我尝试使用flask_migrate
运行迁移时,我的终端挂起,没有任何错误,但是未应用迁移。
我的app.py
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate
import os
app = Flask(__name__)
app.config.from_object(os.environ['APP_SETTINGS'])
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
db = SQLAlchemy(app)
migrate = Migrate(app, db)
from models import User, SiteAccount
@app.route('/')
def hello():
return "Hello World!"
if __name__ == '__main__':
app.run()
和我的配置对象:
class Config(object):
DEBUG = True
TESTING = False
CSRF_ENABLED = True
SECRET_KEY = os.environ['SECRET_KEY']
SQLALCHEMY_DATABASE_URI = 'postgresql+psycopg2://{user}:{pw}@{url}/{db}'.format(user=os.environ['pguser'],pw=os.environ['pgpassword'],url=os.environ['pgurl'],db=os.environ['pgdb'])
编辑:从db uri中删除psycopg2可以达到目的