小编Joh*_*pez的帖子

Flask - (ProgrammingError) - 构建 postgresql 数据库时的外键约束

我目前正在尝试将 Flask 应用程序部署到 Heroku,但在数据库初始化期间遇到错误。

这是我的 models.py 文件:

from app import app  
from app import db  
from werkzeug.security import generate_password_hash, check_password_hash  
from sqlalchemy import create_engine, Column, Integer, String, Date, ForeignKey, event, Boolean, Table  
from sqlalchemy.orm import scoped_session, sessionmaker, backref, relationship  

class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    password = db.Column(db.String(255), nullable=False, server_default='')
    email = db.Column(db.String(255), nullable=False, unique=True, index=True)
    confirmed_at = db.Column(db.DateTime())
    authenticated = db.Column(db.Boolean(), nullable=False, server_default='0')
    company_name = db.Column(db.String(100), nullable=False, server_default='')

    roles = db.relationship('Role')


    def __init__(self, email, company_name, password):
        self.email = email …
Run Code Online (Sandbox Code Playgroud)

python sqlalchemy heroku flask flask-sqlalchemy

4
推荐指数
1
解决办法
1822
查看次数

标签 统计

flask ×1

flask-sqlalchemy ×1

heroku ×1

python ×1

sqlalchemy ×1