Created
June 29, 2010 20:20
-
-
Save unbracketed/457758 to your computer and use it in GitHub Desktop.
Parsing columns out of MySQL table status dump
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
import re | |
tables = open('path/to/table_status_dump').readlines() | |
for table in tables: | |
mo = re.search(r'^\|\s(?P<table_name>[\w_]+)\s+\|\s(InnoDB|MyISAM)\s?\|\s+\d+\s+\|\s(Compact|Fixed|Dynamic)\s+\|\s+(?P<row_count>\d+)\s+\|(\s+\d+\s+)\|\s+(?P<data_length>\d+)\s+\|(\s+\d+\s+)\|\s+(?P<index_length>\d+)\s+\|', table) | |
print ','.join((mo.group('table_name'), mo.group('row_count'), mo.group('data_length'), mo.group('index_length'), ) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment