Simple schema which maps table&column to a unique identifier
| 74 | |
| 75 | |
| 76 | class Schema: |
| 77 | """ |
| 78 | Simple schema which maps table&column to a unique identifier |
| 79 | """ |
| 80 | |
| 81 | def __init__(self, schema): |
| 82 | self._schema = schema |
| 83 | self._idMap = self._map(self._schema) |
| 84 | |
| 85 | @property |
| 86 | def schema(self): |
| 87 | return self._schema |
| 88 | |
| 89 | @property |
| 90 | def idMap(self): |
| 91 | return self._idMap |
| 92 | |
| 93 | def _map(self, schema): |
| 94 | idMap = {'*': "__all__"} |
| 95 | id = 1 |
| 96 | for key, vals in schema.items(): |
| 97 | for val in vals: |
| 98 | idMap[key.lower() + "." + val.lower()] = "__" + key.lower() + "." + val.lower() + "__" |
| 99 | id += 1 |
| 100 | |
| 101 | for key in schema: |
| 102 | idMap[key.lower()] = "__" + key.lower() + "__" |
| 103 | id += 1 |
| 104 | |
| 105 | return idMap |
| 106 | |
| 107 | |
| 108 | def get_schema(db): |