Created
May 18, 2014 18:52
-
-
Save meeuw/397d119543166cca8ee2 to your computer and use it in GitHub Desktop.
generate json dump from mysqldump
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
#!/usr/bin/python | |
import fileinput | |
import json | |
output = {} | |
for line in fileinput.input(): | |
if line.startswith('CREATE TABLE'): | |
table = line.split('`')[1] | |
if line.startswith(' `'): | |
if not table in output: output[table] = {} | |
s = line[2:].split('`') | |
output[table][s[1]] = s[2][:-2] | |
print json.dumps(output) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment