def create_dialect(cls, target: str) -> Dialect: tests_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) test_warehouse_cfg_path = f'{tests_dir}/warehouses/{target}_cfg.yml' with open(test_warehouse_cfg_path, encoding='utf-8') as f: warehouse_configuration_dict = yaml.load(f, Loader=yaml.SafeLoader) dialect_parser = DialectParser(warehouse_configuration_dict) dialect_parser.assert_no_warnings_or_errors() return dialect_parser.dialect
def with_database(self, database: str): warehouse_connection_dict = { 'host': self.host, 'port': self.port, 'username': self.username, 'password': self.password, 'database': database, 'schema': self.schema } if self.aws_credentials: warehouse_connection_dict.update({ 'access_key_id': self.aws_credentials.access_key_id, 'secret_access_key': self.aws_credentials.secret_access_key, 'role_arn': self.aws_credentials.role_arn, 'session_token': self.aws_credentials.session_token, 'region': self.aws_credentials.region }) return RedshiftDialect(DialectParser(warehouse_connection_dict))
def create_for_warehouse_type(cls, warehouse_type): from sodasql.scan.dialect_parser import DialectParser return cls.create( DialectParser( warehouse_connection_dict={KEY_WAREHOUSE_TYPE: warehouse_type }))
def create_dialect(target): return Dialect.create(DialectParser({KEY_WAREHOUSE_TYPE: target}))