Home › Forum › Community › Radiation vs Weather › Reply To: Radiation vs Weather
May 21, 2015 at 4:59 am
#1948
Participant
Here is the python script I’m using to pull data from the uRAD monitor into mysql in case anybody is interested.
import time
import json
import MySQLdb
import urllib2
response = urllib2.urlopen('http://192.168.1.225/j')
html=response.read()
result = json.loads(html)
data = result['data']['temperature']
cpm = result['data']['cpm']
db = MySQLdb.connect(host="localhost",user="username",passwd="password",db="temps")
curs=db.cursor()
try:
curs.execute ("INSERT INTO urad (tdate, time, temperature,cpm) VALUES (CURRENT_DATE(), NOW(), %s, %s) """, (data, cpm))
db.commit()
except db.Error, e:
print "Error %d: %s" % (e.args[0],e.args[1])
db.rollback()
db.close()