title: Storing python dictionary in json file and substitute values upon reading
body: <p>I am attempting to create a system that stores information about a sensor(s) in a json file. So far so good. I can store almost all the data in json and pull it out without issue. </p>
  
  <p>Where I am stuck is with the database calls. This is a basic example of the json file for a fish tank sensor, but there are other that contain different sensor packages</p>
  
  <pre><code>{
      "sensor_info": {
          "name" : "fish tank",
          "unpack_commands" : "floatle:32, floatle:32"
      },
  
      "database_query" : "INSERT INTO fish_tank (pH, temperature, timestamp) VALUES ('%(pH)s', '%(temperature)s', TIMESTAMP(NOW(5)))",
  
      "database_data" : "{'pH': pH, 'temperature': temperature}"
  }
  </code></pre>
  
  <p>Here is the fucntion that calls the data from the json. BTW I am using the bitstring library for this hence the unpack.</p>
  
  <pre><code>def fish_tank(sensor_info, data):
  
      unpack_commands = sensor_info['sensor_info']['unpack_commands']
      sql_statement = sensor_info['database_query']
  
  
      # Unpack the data from the incoming serial data
      pH, temperature = data.unpack(unpack_commands)    
  
      # Create the dictionary for database submission
      # data = sensor_info['database_data']
      data = {'pH': pH, 'temperature': temperature}
  
      Database().write_data(sql_statement, data) 
  </code></pre>
  
  <p>As you can see I store the dictionary of data in the json file, but I am not using it as I can't figure out how to pull in the dictionary from json and have the correct values inserted into the dictionary for writing to the database. The sql query works fine, the unpack works fine, all I need now is the data portion and I can create a generic sensor function (within reason). </p>
  
  <p>Thanks</p>