外键报错

来源:9-6 用户注册

雨木送清风

2019-09-25


from app.models.base import db, Base
from sqlalchemy import Column, Integer, String, Boolean, ForeignKey, desc, func
from sqlalchemy.orm import relationship


__author__ = 'SimonChan'



class Gift(Base):

    id = Column(Integer, primary_key=True)

    user = relationship('User')

    uid = Column(Integer, ForeignKey('user.id'))
    isbn = Column(String(15), nullable=False)
    # book = relationship('Book')
    # bid = Column(Integer, ForeignKey('user.id'))
    launched = Column(Boolean, default=False)



from app.models.base import db, Base

from sqlalchemy import Column, Integer, String, Boolean, Float

__author__ = 'SimonChan'


class User(Base):
    # __tablename__ = 'user'
    id = Column(Integer, primary_key=True)
    nickname = Column(String(24), nullable=False)
    phone_number = Column(String(18), unique=True)
    # _password = Column('password', String(128), nullable=False)
    email = Column(String(50), unique=True, nullable=False)
    confirmed = Column(Boolean, default=False)
    beans = Column(Float, default=0)
    send_counter = Column(Integer, default=0)
    receive_counter = Column(Integer, default=0)
    wx_open_id = Column(String(50))
    wx_name = Column(String(32))



图片描述

写回答

1回答

7七月

2019-09-25

提示是没有找到user 这张表。我觉得核对下源代码看看吧。

0
5
7七月
回复
雨木送清风
不会。不行你就直接把源码看看复制过去呗。
2019-09-25
共5条回复

Python Flask高级编程之从0到1开发《鱼书》精品项目

7月老师深入浅出剖析Flask核心机制,和你一起探讨Python高级编程

2735 学习 · 1267 问题

查看课程