DomainsDictionary
A DomainsDictionary is used to map an entire database from an arbitrary schema to a PhenEx internal representation.
Attributes:
| Name | Type | Description |
|---|---|---|
domains_dict |
Dict[str, class]
|
A dictionary where keys are domain names and values are uninstantiated PhenexTable class objects. |
Methods:
| Name | Description |
|---|---|
get_mapped_tables |
Get all tables mapped to PhenEx representation using the given connection. |
get_source_tables |
Get all source tables using the given connection. |
set_mapped_tables |
Create a view for all mapped tables in the destination database. |
Source code in phenex/mappers.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | |
from_dict(data)
staticmethod
Reconstruct a DomainsDictionary from serialized data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict
|
Serialized DomainsDictionary configuration |
required |
Returns:
| Type | Description |
|---|---|
DomainsDictionary
|
DomainsDictionary instance with mapper classes |
Source code in phenex/mappers.py
get_mapped_tables(con)
Get all tables mapped to PhenEx representation using the given connection.
If a database is not provided, the current database of the connection is used to find the tables.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
con
|
The connection to the database. |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, PhenexTable]
|
Dict[str, PhenexTable]: A dictionary where keys are domain names and values are mapped tables. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If a required table is not found in the database. |
Source code in phenex/mappers.py
get_source_tables(con)
Get all source tables using the given connection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
con
|
The connection to the database. |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, str]
|
Dict[str, str]: A dictionary where keys are the source table names and values are table names. |
Source code in phenex/mappers.py
set_mapped_tables(con, overwrite=False)
Create a view for all mapped tables in the destination database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
con
|
The connection to the database. |
required | |
overwrite
|
Whether to overwrite existing views if found. Otherwise, throws an error. |
False
|
Returns:
| Type | Description |
|---|---|
Dict[str, Table]
|
Dict[str, Table]: A dictionary where keys are domain names and values are mapped tables. |
Source code in phenex/mappers.py
to_dict()
Serialize the DomainsDictionary configuration.
This serializes the mapping of domain names to PhenexTable classes, storing only the class configuration, not any actual table data.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
Serialized domains dictionary configuration |