Created
September 20, 2016 19:52
-
-
Save liam-middlebrook/e77fd7726f699293aedf03c93d50235a to your computer and use it in GitHub Desktop.
CSH-WebNews uid to uuid Converter Script
This file contains hidden or 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
#!/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