NoReferencedTableError: Foreign key associated with column ** with which to generate a foreign key to target column 'id'
1.使用 python flask 框架做项目时,在实体类中配置了 映射关系,
message:
id = db.Column(db.Integer, primary_key=True)
message_type_id = db.Column(db.Integer, db.ForeignKey('message_type.id'))
message_type:
- _tablename__ = 'message_type'
id = db.Column(db.Integer, primary_key=True,autoincrement=True)
content = db.Column(db.String(1500))
访问到查询方法时一直报错:
NoReferencedTableError: Foreign key associated with column 'message.message_type_id' could not find table 'message_type' with which to generate a foreign key to target column 'id'
通过调试跟踪代码,发现 message_type 类没有实例化,所以在调用main.py 启动项目时,一定要加载到message_type 将它写入 mod_*中,实例化
NoReferencedTableError: Foreign key associated with column ** with which to generate a foreign key to target column 'id'的更多相关文章
- 有两个表A和B,均有key和value两个字段,如果B的key在A中也有,就把B的value替换为A中对应的value
update B b set b.value=(select max(a.value) from A a where b.key=a.key) from A c where b.key=c.key) ...
- 爬坑系列----Redis查询key报空指针异常,而redis中确实存在该key
现象: 1.在A方法中根据key查询一个list,可以获取到相应的值 2.在B方法中同样调用此方法,传入相同的key,查询不到值,为null,报空指针异常 起初我也一脸懵逼,到现在虽然解决了,还是不知 ...
- Cassandra二级索引原理——新创建了一张表格,同时将原始表格之中的索引字段作为新索引表的Primary Key,并且存储的值为原始数据的Primary Key,然后再通过pk一级索引找到真正的值
1.什么是二级索引? 我们前面已经介绍过Cassandra之中有各种Key,比如Primary Key, Cluster Key 等等.如果您对这部分概念并不熟悉,可以参考之前的文章: [Cassan ...
- 已有使用Key登陆机器,创建新账号并使用新Key登陆
背景信息:CentOS6.9机器,目前是使用Key进行登陆的,现在需要创建一个新账号并使用新生成的Key进行登陆使用 使用连接Linux工具:XShell 1.在当前机器中创建一个新用户: # use ...
- 关于 git 本地创建 SSH Key 遇到的一点问题(①file to save the key & ②the authenticity of host...)
背景 由于想测试一下 SSH Key 创建的路径(.ssh 目录路径)对于不同位置 git 项目是否有效. 比如,.ssh 默认在 C:\[users]\[username] 目录下,而项目 proj ...
- react random key generator;react如何产生随机不重复的key
1.<div key={+new Date() + Math.random()}> 2.使用数组的索引 3.使用uuid:https://www.npmjs.com/package/uui ...
- Azure Key Vault (2) 使用Azure Portal创建和查看Azure Key Vault
<Windows Azure Platform 系列文章目录> 请注意: 文本仅简单介绍如何在Azure Portal创建和创建Key Vault,如果需要结合Application做二次 ...
- 60.extjs-布局 (在column布局中使用fieldset 和 在fieldset中使用column布局)
转自:https://blog.csdn.net/snn1410/article/details/8817821/ 在标准的html中,需要把输入项都放到fieldset中,一次来显示分组结构.虽然E ...
- JavaScript中获取Map集合中的key和value值(前提是:既不知道key为什么值,也不知道value有哪些值)
for(var i in maps){//通过定义一个局部变量i遍历获取map里面的所有key值 alert(maps[i]); //通过获取key对应的value值 }
随机推荐
- eclipse 去掉Eclipse打开后定期弹出Usage Data Upload对话框
Eclipse 的 UDC 老定期蹦出来说要上传使用数据到 eclipse 官网服务器去除方法: 1.删除 eclipse/plugins 目录下以 org.eclipse.epp.usagedata ...
- bzoj 3236: [Ahoi2013]作业(缺线段树)
3236: [Ahoi2013]作业 Time Limit: 100 Sec Memory Limit: 512 MBSubmit: 1744 Solved: 702[Submit][Status ...
- POJ--2112--Optimal Milking【Floyd+Dinic+二分答案】
链接:http://poj.org/problem?id=2112 题意:有k个挤奶器.编号1~k,c头牛,编号k+1~k+c,每一个挤奶器最多能给m头牛挤奶,给你一个k+c的邻接矩阵.要求每头牛都能 ...
- Linux--对文件夹下的配置文件批量改动IP
sed -i 's/10.1.1.1/10.1.1.2/g' `grep -ir 10.1.1.1 * |grep -E '.xml:|.cfg:|.ini:|.wsdl:|.properties:' ...
- 造个简单的轮子倒是不难,但可用性健壮性高到qt这样全世界都在用,就几乎不可能了
造个简单的轮子倒是不难,但可用性健壮性高到qt这样全世界都在用,就几乎不可能了比如自己写个事件循环实现信号槽,还真不难,我这边的架构里就这么搞了个仿osgi的事件总线嵌入式实时操作系统上能用的大型gu ...
- mysqlbinlog高速遍历搜索记录
目标,开发者说有个数据莫名其妙加入了.可是不知道是从哪里加入的.并且应用功能里面不应该加入这种数据,为了查清楚来源,所以我就准备去binlog里面找了.可是binlog有好几个月的数,我这样一个个my ...
- gdb help all 帮助信息
Command class: aliases ni -- Step one instruction rc -- Continue program being debugged but run it i ...
- 均匀分布(uniform distribution)期望的最大似然估计(maximum likelihood estimation)
maximum estimator method more known as MLE of a uniform distribution [0,θ] 区间上的均匀分布为例,独立同分布地采样样本 x1, ...
- 2017-3-6 leetcode 118 169 189
今天什么都没发生 ================================================= leetcode118 https://leetcode.com/problems ...
- USACO 2.1 Hamming Codes
Hamming CodesRob Kolstad Given N, B, and D: Find a set of N codewords (1 <= N <= 64), each of ...