首页 > 数据库技术 > 详细

Python之SQLAlchemy学习--外键约束问题

时间:2015-12-09 13:50:41      阅读:350      评论:0      收藏:0      [点我收藏+]

以下问题赞为解决:

# class User(Base):
# __tablename__ = ‘user‘
# #表的结构
# id = Column(String(20), primary_key=True)
# username = Column(String(20))
# books = relationship(‘Book‘)
# class Book(Base):
# __tablename__ = ‘book‘
#
# id = Column(String(20), primary_key=True)
# name = Column(String(20))
# # “多”的一方的book表是通过外键关联到user表的:
# user_id = Column(String(20), ForeignKey(‘user.id‘))

Python之SQLAlchemy学习--外键约束问题

原文:http://www.cnblogs.com/mxh1099/p/5032387.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!