Skip to content

Instantly share code, notes, and snippets.

@unbracketed
Created June 29, 2010 20:20
Show Gist options
  • Save unbracketed/457758 to your computer and use it in GitHub Desktop.
Save unbracketed/457758 to your computer and use it in GitHub Desktop.
Parsing columns out of MySQL table status dump
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