Skip to content

Instantly share code, notes, and snippets.

@ryandotclair
Last active December 10, 2015 05:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryandotclair/118a1443892814ff1b4e to your computer and use it in GitHub Desktop.
Save ryandotclair/118a1443892814ff1b4e to your computer and use it in GitHub Desktop.
does_record_exist.py
try:
cursor = db_connection.cursor()
SQL = "SELECT EXISTS (SELECT key FROM reporterschema.main WHERE date = %s AND sn = %s AND sg = %s)"
DATA = (timestamp, symmetrix_id, storage_group_id)
cursor.execute(SQL, DATA)
if cursor.fetchall()[0][0]:
logger.warning("Record already exists in the database, skipping. Date:{0}, SN:{1}, "
"SG:{2}".format(timestamp, symmetrix_id, storage_group_id))
cursor.close()
continue
else:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment