Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def validate_params(self):
"""
Validate database parameters.
Should validate that a dbtype is a valid one and that the appropriate
params have been passed for a particular db_type.
:raises ETLHelperParamsError: Error if params are invalid
"""
# Get a set of the attributes to compare against required attributes.
given = set(self.keys())
try:
required_params = DB_HELPER_FACTORY.from_dbtype(self.dbtype).required_params
except ETLHelperHelperError:
msg = f'{self.dbtype} not in valid types ({DB_HELPER_FACTORY.helpers.keys()})'
raise ETLHelperDbParamsError(msg)
unset_params = (given ^ required_params) & required_params
if unset_params:
msg = f'{unset_params} not set. Required parameters are {required_params}'
raise ETLHelperDbParamsError(msg)