-
-
Save guillermo-menjivar/889966531fc420758eb23377c11ce932 to your computer and use it in GitHub Desktop.
take-20123121
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
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