Skip to content

Instantly share code, notes, and snippets.

@guillermo-menjivar
Last active January 16, 2018 06:42
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 guillermo-menjivar/889966531fc420758eb23377c11ce932 to your computer and use it in GitHub Desktop.
Save guillermo-menjivar/889966531fc420758eb23377c11ce932 to your computer and use it in GitHub Desktop.
take-20123121
def hack_convert(records):
template = "select * from analytics where tag in ({CODE})"
root = "(VALUES "
for rec in records:
root = root + "('"+rec+"'::uuid),"
# this removes the last comma
root = root[:-1]
root = root + ")"
return root
TEMPLATE = """UPDATE analytics SET updated = now() WHERE tag_uuid IN {UUIDS}"""
def update_records(tag_id, uuids):
"running against", len(uuids)
structured_uuids = hack_convert(uuids)
print structured_uuids
query = TEMPLATE.format(UUIDS=structured_uuids, IPS=structured_uuids)
print 'executing function - psql call execute'
#print tag_cursor.mogrify(query)
tag_cursor.execute(query)
print 'finish running exec'
#s("analyticsd.update.record")
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment