Skip to content

Instantly share code, notes, and snippets.

@ThiefMaster
Created March 9, 2015 16:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ThiefMaster/176b929d8ef3f0902397 to your computer and use it in GitHub Desktop.
Save ThiefMaster/176b929d8ef3f0902397 to your computer and use it in GitHub Desktop.
from indico.util.console import cformat
colors = {
'fk': 'yellow!',
'pk': 'red!',
'ix': 'green!',
'ck': 'cyan!',
'uq': 'blue!'
}
def print_stuff(table):
t = db.Model.metadata.tables[table]
print t.name
for c in sorted(t.constraints, key=lambda x: x.name):
if c._create_rule and isinstance(c._create_rule.target, db.Boolean):
continue
color = colors[c.name[:2]]
print cformat(' - %%{%s}{}%%{reset}' % color).format(c.name)
for idx in sorted(t.indexes, key=lambda x: x.name):
color = colors[idx.name[:2]]
print cformat(' - %%{%s}{}%%{reset}' % color).format(idx.name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment