G2Config

G2Config modifies an in-memory configuration.

from senzing import G2Config, G2Exception

Configuration object management

init

init() initializes the G2Config object. It must be called prior to any other calls.

g2_config.init(g2_object_name, senzing_config_json, verbose_logging)
Parameters
  • g2_object_name: (str) A short name given to this instance of the G2Config object, to help identify it within system logs.
  • senzing_config_json: (str) A JSON string containing configuration parameters.
  • verbose_logging: (bool [optional]) (default False) Enables diagnostic logging. False for no logging; True for logging.
Click to expand init() example

create

create() creates an editable in-memory configuration from the default template configuration JSON stored in the product installation. It also creates a handle pointer to the configuration. The handle is used by the addDataSource(), listDataSources(), deleteDataSource(), and save() methods. The handle is terminated by the close() method.

g2_config.create()
Parameters

create() has no parameters.

Click to expand create() example

save

save() exports an in-memory configuration as a JSON string.

g2_config.save(config_handle, saved_config_json)
Parameters
  • config_handle: (int) the handle pointer to the in-memory configuration.
  • saved_config_json: (bytearray) Object to store the output of the method.
Click to expand save() example

load

load() creates an editable in-memory configuration from an configuration JSON input string. It also creates a handle pointer to the configuration. The handle is used by the addDataSource(), listDataSources(), deleteDataSource(), and save() methods. The handle is terminated by the close() method.

g2_config.load(config_json)
Parameters
  • config_json: (bytearray) the config data to load into the config handle.
Click to expand load() example

Datasource management

listDataSources

listDataSources() returns a list of data sources contained in an in-memory configuration.

g2_config.listDataSources(config_handle, response_bytearray)
Parameters
  • config_handle: (int) the handle pointer to the in-memory configuration.
  • response_bytearray: (bytearray) Object to store the output of the method.
Click to expand listDataSources() example

addDataSource

addDataSource() adds a new data source to a G2Config object.

g2_config.addDataSource(config_handle, datasource_json, response_bytearray)
Parameters
  • config_handle: (int) the handle pointer to the in-memory configuration.
  • datasource_json: (str) A JSON document in the format {"DSRC_CODE": "NAME_OF_DATASOURCE"}
  • response_bytearray: (bytearray) Object to store the output of the method.
Click to expand addDataSource() example

deleteDataSource

deleteDataSource() removes a data source from a G2Config object.

g2_config.deleteDataSource(config_handle, datasource_json)
Parameters
  • config_handle: (int) the handle pointer to the in-memory configuration.
  • datasource_json: (str) A JSON document in the format {"DSRC_CODE": "NAME_OF_DATASOURCE"}
Click to expand deleteDataSource() example

Configuration object cleanup

close

close() cleans up an in-memory configuration.

g2_config.close(config_handle)
Parameters
  • config_handle: (int) the handle pointer to the in-memory configuration.
Click to expand close() example

destroy

destroy() destroys and performs cleanup for the G2Config object and any in-memory configurations.

g2_config.destroy(config_handle)
Click to expand destroy() example