INSERTINTO查询python中的字符串和显示?

问题描述:

一读JSON文件:INSERTINTO查询python中的字符串和显示?

import json 
from pprint import pprint 

with open('data.json') as data_file:  
data = json.load(data_file) 

pprint(data) 

阅读JSON文件后,我想不是所有的获取只能从JSON一些参数。

like:temperature 1,temperature 2,timestamp

after that; 我想在一个LIST或对象 中作为字符串实现一些INSERT INTO查询并打印该LIST。

在那插入查询,我想要插入一些五条记录并显示那条记录。

请帮我看看这个脚本。

+0

你想追加列表中的值还是将它们插入到数据库中? – Serjik

+1

这里'data'是一个字典。因为我们不知道这本字典是怎么样的,所以我们无法帮助你。 –

+0

使用此:http://stackoverflow.com/documentation/python/272/json-module#t=201611130550527723123和此:http://stackoverflow.com/documentation/search?tag=python&query=sql –

一旦你的JSON内容的数据变量,您可以使用属性的名称访问它,你想访问为指标

list_values=[] 
list_values.append(data['temperature 1']) #add all the values to the list 
print(list_values) 

你可以把json的值,以同样的方式你对待字典。

+0

以及如何将INSERT INTO qurey添加为字符串? –

+0

我们如何插入新数据? –

+0

在列表中使用append操作 –