Last active
December 10, 2015 05:21
-
-
Save ryandotclair/118a1443892814ff1b4e to your computer and use it in GitHub Desktop.
does_record_exist.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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