This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This is useful for when an orm model has a property that references a column that has a different name | |
| class Model(): | |
| __table_name__ = "sometable" | |
| legacy_id = Column("id", Integer) | |
| attrs = Model.__mapper__ # or inspect(Model) | |
| {c.key: c.columns[0].key for c in attrs.column_attrs} | |
| # {'legacy_id': 'id'} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import inspect | |
| import os | |
| from functools import wraps | |
| def env_override(func): | |
| sig = inspect.signature(func) | |
| # Identify parameters with default value None | |
| none_defaults = [ | |
| name for name, param in sig.parameters.items() | |
| if param.default is None |
OlderNewer