TB.M TB.M - 7 months ago 44
Python Question

INSERTINTO Query in python as a String and Display?

first reading Json file:

import json
from pprint import pprint

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


after reading json file,i want to fetch only some parameters from json not all.

like: temperature 1,temperature 2,timestamp

after that;
i want to implement some INSERT INTO query as a String in one LIST or Object
and print that LIST.

In that insert Query, i want to insert some five records and display that records.

Please help me out with this script.


Once you have the json content to the data variable, you can access it using the name of the attribute you would like to access as index

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

You can treat the json values, the same way you treat the dictionary.