#!/usr/bin/env python DRUPAL_URL='http://192.168.1.50/~nigel/drupal47/xmlrpc.php' DRUPAL_USERNAME='nigel' DRUPAL_PASSWORD='trustno1' DRUPAL_STATIONID='6551' DB_NAME='open2300' DB_USERNAME='open2300' DB_PASSWORD='open2300' DB_HOST='localhost' import xmlrpclib import MySQLdb s = xmlrpclib.ServerProxy(DRUPAL_URL) conn = MySQLdb.connect(host=DB_HOST, user=DB_USERNAME, passwd=DB_PASSWORD, db=DB_NAME) cur = conn.cursor(MySQLdb.cursors.DictCursor) # Select the newest record if cur.execute("SELECT * FROM `weather` ORDER BY `timestamp` DESC LIMIT 1;") == 1: row = cur.fetchone() # convert all elements to strings for i in row: row[i] = str(row[i]) print s.openweather.addEntry(DRUPAL_STATIONID, DRUPAL_USERNAME, DRUPAL_PASSWORD, row) cur.close() conn.close()