Simple schema which maps table&column to a unique identifier
| 46 | |
| 47 | |
| 48 | class Schema: |
| 49 | """ |
| 50 | Simple schema which maps table&column to a unique identifier |
| 51 | """ |
| 52 | def __init__(self, schema): |
| 53 | self._schema = schema |
| 54 | self._idMap = self._map(self._schema) |
| 55 | |
| 56 | @property |
| 57 | def schema(self): |
| 58 | return self._schema |
| 59 | |
| 60 | @property |
| 61 | def idMap(self): |
| 62 | return self._idMap |
| 63 | |
| 64 | def _map(self, schema): |
| 65 | idMap = {'*': "__all__"} |
| 66 | id = 1 |
| 67 | for key, vals in schema.items(): |
| 68 | for val in vals: |
| 69 | idMap[key.lower() + "." + val.lower()] = "__" + key.lower() + "." + val.lower() + "__" |
| 70 | id += 1 |
| 71 | |
| 72 | for key in schema: |
| 73 | idMap[key.lower()] = "__" + key.lower() + "__" |
| 74 | id += 1 |
| 75 | |
| 76 | return idMap |
| 77 | |
| 78 | |
| 79 | def get_schema(db): |