Skip to content

Instantly share code, notes, and snippets.

@liam-middlebrook
Created September 20, 2016 19:52
Show Gist options
  • Save liam-middlebrook/e77fd7726f699293aedf03c93d50235a to your computer and use it in GitHub Desktop.
Save liam-middlebrook/e77fd7726f699293aedf03c93d50235a to your computer and use it in GitHub Desktop.
CSH-WebNews uid to uuid Converter Script
#!/usr/bin/python
# Copyright 2016 Liam Middlebrook
# Available Under GPLv3
# Contact for other licensing
import csh_uuid
lines = []
# load infile
with open('input.sql') as f:
lines = f.read().splitlines()
# write to outfile
with open('output.sql', 'w') as f:
# convert uuids
for l in lines:
if 'INSERT' in l:
statement = l.split('(')[1]
username = statement.split('\'')[1]
new_statement = l.replace(username, csh_uuid.get_uuid_from_uid(username), 1)
f.write("{}\n".format(new_statement))
else:
f.write("{}\n".format(l))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment