Skip to content

Instantly share code, notes, and snippets.

@ryandotclair
Last active November 28, 2015 02:18
Show Gist options
  • Save ryandotclair/48bcab655a5f2dd33ee1 to your computer and use it in GitHub Desktop.
Save ryandotclair/48bcab655a5f2dd33ee1 to your computer and use it in GitHub Desktop.
db write out
# Grab Total MB Sent for a given SG and write out the data to the database.
for item in result:
srdfa_total += item['SRDFA_MBSent']
try:
print("Writing to the the database: {0}, {1}, {2}, {3}".format(
timestamp, symmetrix_id, storage_group_id, srdfa_total))
cursor = db_connection.cursor()
SQL = "INSERT INTO reporterschema.main (date, sn, sg, srdfa_mbsent) VALUES (%s,%s,%s,%s)"
DATA = (timestamp, symmetrix_id, storage_group_id, srdfa_total)
cursor.execute(SQL, DATA)
cursor.close()
except Exception as e:
logger.critical("Table doesn't exist or is improperly configured!\n{0}".format(e))
sys.exit(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment