예제 #1
0
 def test_get_redshift_host(self):
     file_path = '/test/testconfig.ini'
     with open(self.config_path) as f:
         config_contents = f.read()
     self.fs.create_file(file_path, contents=config_contents)
     config = read_redshift_config_file(file_path)
     self.assertEqual(get_redshift_host(config), 'test-host')
 def get_connection(self, schema: Optional[str]) -> Any:
     assert schema is not None and len(schema) > 0
     credentials = self.connection_attr[__CREDENTIALS__]
     return psycopg2.connect(dbname=schema,
                             host=config_helper.get_redshift_host(self.connection_attr),
                             port=config_helper.get_redshift_port(self.connection_attr),
                             user=credentials.user,
                             password=credentials.password)
예제 #3
0
 def get_config_params_dict(self, schema: Optional[str], credentials: Credential) -> Dict:
     config_params = {
         "host": config_helper.get_redshift_host(self.connection_attr),
         "port": config_helper.get_redshift_port(self.connection_attr),
         "user": credentials.user,
         "password": credentials.password
     }
     if schema:
         config_params['db'] = schema
     if 'ssl-cert' in self.connection_attr:
         config_params['ssl'] = {
             "cert": self.connection_attr['ssl-cert'],
             "ca": self.connection_attr['ssl-ca'],
             "key": self.connection_attr['ssl-key']
         }
     return config_params
 def get_uri(self, schema: Optional[str]) -> str:
     assert schema is not None and len(schema) > 0
     credentials = self.connection_attr[__CREDENTIALS__]
     host = config_helper.get_redshift_host(self.connection_attr)
     port = config_helper.get_redshift_port(self.connection_attr)
     return f'{self.engine_name}://{credentials.user}:{credentials.password}@{host}:{port}/{schema}'