Skip to content

Instantly share code, notes, and snippets.

@jaklinger
Created June 1, 2020 13:30
Show Gist options
  • Save jaklinger/cfb330c501379b7ae14a0fd77e05f65d to your computer and use it in GitHub Desktop.
Save jaklinger/cfb330c501379b7ae14a0fd77e05f65d to your computer and use it in GitHub Desktop.
dump schema from data_getters
from collections import defaultdict
ignore = ["2020", "onsOpenGeo", 'worldbank', 'table_updates']
out_data = defaultdict(dict)
for dataset, tables in schemas.items():
for name, table in tables.items():
if any(i in name for i in ignore):
continue
table = [dict(field_name=str(c.key), type=str(c.type), primary_key=c.primary_key, nullable=c.nullable)
for c in table.columns]
out_data[dataset][name] = table
with open("schema_dump.yaml", "w") as f:yaml.dump(dict(out_data), f, allow_unicode=True, indent=4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment