如题,用 python 处理下数据库内容,发现数据都以 json 字符串保存在一列里面。 想用 flask 把数据显示出来,有啥好办法没?必须得读取后用 json dump 处理,我看 mysql5.7 支持 json 直接处理,这里数据项太多,查询不知道速度然后!
数据列是这样的
`id`, `create_time`, `json_str`, `time`, `type`, `typeshow`, `uid`
json 数据保存在 json_str 这列
json_str 这列内容如下
{"address":"内蒙古自治区包头市农村商业银行(狮西分理处)","bianhao":"","changguiid":0,"lat":"23.177047526041665","lishiid":3,"lon":"112.96525254991319","pi3LiangEntity":{"biaozhunzhi":"","ceshitiaojian":1,"ceshitiaojianShow":"压","chongdia3nzhuangtai":0,"chongdianzhuangtaiShow":"充","dianchi3biaozhun":"","dianchileixing":"普通","dianchi3pingpai":"","hegedianyazhi":"12.60","lingbujianhaop":"105","pi3LiangItemEntityList":[{"beizhu":"","dianya":"12.8","dianya2":"","erweima":"","hege1":"","hege2":"","jieguo":"","piliangid":4,"piliangitemid":9,"qicheerweima":"","qicheshoudongma":"","shoudongma":"","soc":0,"soh":0,"time":1546759767792}],"piliangid":4,"riqima":"","zifu":""},"piliangid":4,"time":1546759757201,"timeShow":"2019-1-6 15:29:17","type":0,"uid":1,"xiTongEntity":{"beizhu":"","dianchima":"","dianya1":"","dianya2":"","dianya3":"","dianya4":"","erweidianchima":"","erweiqichema":"","gaodi1":"","gaodi2":"","gaodi3":"","gaodi4":"","qichema":"","time":0,"xitongid":0},"xitongid":0}
1
aliipay 2019-02-24 13:45:18 +08:00 via Android 1
病句太多,不知道问题是什么,无法回答
|
2
Wisho 2019-02-24 14:13:53 +08:00
如果经常要对 json 里的某个字段进行查询,建议单独把这一列抽出来成为一张独立的表......或者灌到 es 里做索引。
|
3
qile1 OP @aliipay 谢谢回复,我意思是 mysql 数据库里面的数据是以 text 格式保存到表里面的,用 python 语言连接数据库后该如何查询这些数据。
数据库里面某行的“ json_str ” 这列是上面的内容 |
4
leoleoasd 2019-02-24 14:33:35 +08:00
你已经说了 读取出字符串后 dump 处理
已经是 TEXT 格式的话 没法用 mysql 提供的 json 吧 |
5
iyaozhen 2019-02-24 14:43:22 +08:00 via Android
5.7 后就支持 json 查询,但是无法索引。
|