Adding Records
addRecord
addRecord() loads a record into the Senzing repository. Can be called as many times as desired and from multiple threads at the same time.
g2_engine.addRecord(datasource_code, record_id, data_as_json, load_id)
Parameters
- datasource_code: (str) The configured data source for the record.
- record_id: (str) The RECORD_ID for the record.
- data_as_json: (str) A JSON document with the attribute data for the record.
- load_id: (str [optional] ) the observation load ID for the record. The value can be null.
Click to expand `addRecord()` example
Example
#! /usr/bin/env python3
from senzing import G2Engine, G2Exception
# REPLACE /home/user/your_project with the path to your Senzing project
senzing_engine_configuration_json = '{ "PIPELINE": { "CONFIGPATH": "/home/user/your_project/etc", "SUPPORTPATH": "/home/user/your_project/data", "RESOURCEPATH": "/home/user/your_project/resources" }, "SQL": { "CONNECTION": "sqlite3://na:na@/home/user/your_project/var/sqlite/G2C.db" } }'
g2_engine = G2Engine()
datasource_code = 'CUSTOMERS'
record_id = '1001'
load_id = 'Add Record CUSTOMERS 1001'
data_as_json = '{"ADDR_LINE1":"123 Main Street, Las Vegas NV 89132","ADDR_TYPE":"MAILING","AMOUNT":"100","DATE":"1/2/18","DATE_OF_BIRTH":"12/11/1978","EMAIL_ADDRESS":"[email protected]","PHONE_NUMBER":"702-919-1300","PHONE_TYPE":"HOME","PRIMARY_NAME_FIRST":"Robert","PRIMARY_NAME_LAST":"Smith","RECORD_TYPE":"PERSON","STATUS":"Active","DATA_SOURCE":"CUSTOMERS"}'
response_bytearray = bytearray()
try:
g2_engine.init("G2Engine", senzing_engine_configuration_json)
g2_engine.addRecord(
datasource_code,
record_id,
data_as_json,
load_id)
g2_engine.destroy()
except G2Exception as err:
print(err)
addRecordWithInfo
addRecordWithInfo loads a record into the Senzing repository, and returns a JSON document containing the ENTITY_ID values of the affected entities.
g2_engine.addRecordWithInfo(datasource_code, record_id, data_as_json, response_bytearray, load_id)
Parameters
- datasource_code: (str) The configured data source for the record.
- record_id: (str) The RECORD_ID for the record.
- data_as_json: (str) A JSON document with the attribute data for the record.
- response_bytearray: (bytearray) Object to store the output of the method.
- load_id: (str [optional] ) the observation load ID for the record. The value can be null.
Click to expand `addRecordWithInfo()` example
Example
#! /usr/bin/env python3
from senzing import G2Engine, G2Exception
# REPLACE /home/user/your_project with the path to your Senzing project
senzing_engine_configuration_json = '{ "PIPELINE": { "CONFIGPATH": "/home/user/your_project/etc", "SUPPORTPATH": "/home/user/your_project/data", "RESOURCEPATH": "/home/user/your_project/resources" }, "SQL": { "CONNECTION": "sqlite3://na:na@/home/user/your_project/var/sqlite/G2C.db" } }'
g2_engine = G2Engine()
datasource_code = 'CUSTOMERS'
record_id = '1001'
data_as_json = '{"ADDR_LINE1":"123 Main Street, Las Vegas NV 89132","ADDR_TYPE":"MAILING","AMOUNT":"100","DATE":"1/2/18","DATE_OF_BIRTH":"12/11/1978","EMAIL_ADDRESS":"[email protected]","PHONE_NUMBER":"702-919-1300","PHONE_TYPE":"HOME","PRIMARY_NAME_FIRST":"Robert","PRIMARY_NAME_LAST":"Smith","RECORD_TYPE":"PERSON","STATUS":"Active","DATA_SOURCE":"CUSTOMERS"}'
response_bytearray = bytearray()
try:
g2_engine.init("G2Engine", senzing_engine_configuration_json)
g2_engine.addRecordWithInfo(
datasource_code,
record_id,
data_as_json,
response_bytearray)
g2_engine.destroy()
print(response_bytearray.decode())
except G2Exception as err:
print(err)
Output
{
"DATA_SOURCE": "CUSTOMERS",
"RECORD_ID": "1001",
"AFFECTED_ENTITIES": [
{
"ENTITY_ID": 1
}
],
"INTERESTING_ENTITIES": {
"ENTITIES": []
}
}
addRecordWithReturnedRecordID
addRecordWithReturnedRecordID() loads a record into the Senzing repository without a record_id parameter, and returns the RECORD_ID of the loaded record.
While the record is not loaded using a record_id parameter, a RECORD_ID can be included in the JSON.
g2_engine.addRecordWithReturnedRecordID(datasource_code, record_id, data_as_json, response_bytearray, load_id)
Parameters
- datasource_code: (str) The configured data source for the record.
- record_id: (bytearray) Object to store the output of the method.
- data_as_json: (str) A JSON document with the attribute data for the record
- load_id: (str [optional] ) the observation load ID for the record. The value can be null.
Click to expand `addRecordWithReturnedRecordID()` example
Example
#! /usr/bin/env python3
from senzing import G2Engine, G2Exception
# REPLACE /home/user/your_project with the path to your Senzing project
senzing_engine_configuration_json = '{ "PIPELINE": { "CONFIGPATH": "/home/user/your_project/etc", "SUPPORTPATH": "/home/user/your_project/data", "RESOURCEPATH": "/home/user/your_project/resources" }, "SQL": { "CONNECTION": "sqlite3://na:na@/home/user/your_project/var/sqlite/G2C.db" } }'
g2_engine = G2Engine()
datasource_code = 'CUSTOMERS'
load_id = 'Add Record CUSTOMERS no RECORD_ID'
data_as_json = '{"ADDR_LINE1":"123 Main Street, Las Vegas NV 89132","ADDR_TYPE":"MAILING","AMOUNT":"100","DATE":"1/2/18","DATE_OF_BIRTH":"12/11/1978","EMAIL_ADDRESS":"[email protected]","PHONE_NUMBER":"702-919-1300","PHONE_TYPE":"HOME","PRIMARY_NAME_FIRST":"Robert","PRIMARY_NAME_LAST":"Smith","RECORD_TYPE":"PERSON","STATUS":"Active","DATA_SOURCE":"CUSTOMERS","ENTITY_TYPE":"GENERIC","DSRC_ACTION":"A"}'
record_id = bytearray()
try:
g2_engine.init("G2Engine", senzing_engine_configuration_json)
g2_engine.addRecordWithReturnedRecordID(
datasource_code,
record_id,
data_as_json,
load_id)
g2_engine.destroy()
print(record_id.decode())
except G2Exception as err:
print(err)
Response message:
0792BE1EA1E3FFFEB53AC53AF8199EF26F4C73CA
addRecordWithInfoWithReturnedRecordID
addRecordWithInfoWithReturnedRecordID() loads a record into the Senzing repository without a record_id parameter, and returns the RECORD_ID of the loaded record and a JSON document containing The RECORD_ID and the ENTITY_IDs of the affected entities.
While the record is not loaded using a record_id parameter, a RECORD_ID can be included in the JSON.
g2_engine.addRecordWithInfoWithReturnedRecordID(datasource_code, data_as_json, response_bytearray, record_id, load_id)
Parameters
- datasource_code: (str) The configured data source for the record.
- data_as_json: (str) A JSON document with the attribute data for the record
- response_bytearray: (bytearray) Object to store the output of the method.
- record_id: (bytearray) Object to store the output of the method.
- load_id: (str [optional] ) the observation load ID for the record. The value can be null.
Click to expand `addRecordWithInfoWithReturnedRecordID()` example
Example
#! /usr/bin/env python3
from senzing import G2Engine, G2Exception
# REPLACE /home/user/your_project with the path to your Senzing project
senzing_engine_configuration_json = '{ "PIPELINE": { "CONFIGPATH": "/home/user/your_project/etc", "SUPPORTPATH": "/home/user/your_project/data", "RESOURCEPATH": "/home/user/your_project/resources" }, "SQL": { "CONNECTION": "sqlite3://na:na@/home/user/your_project/var/sqlite/G2C.db" } }'
g2_engine = G2Engine()
datasource_code = 'CUSTOMERS'
load_id = 'Add Record CUSTOMERS no RECORD_ID'
data_as_json = '{"ADDR_LINE1":"123 Main Street, Las Vegas NV 89132","ADDR_TYPE":"MAILING","AMOUNT":"100","DATE":"1/2/18","DATE_OF_BIRTH":"12/11/1978","EMAIL_ADDRESS":"[email protected]","PHONE_NUMBER":"702-919-1300","PHONE_TYPE":"HOME","PRIMARY_NAME_FIRST":"Robert","PRIMARY_NAME_LAST":"Smith","RECORD_TYPE":"PERSON","STATUS":"Active"}'
record_id = bytearray()
response_bytearray = bytearray()
try:
g2_engine.init("G2Engine", senzing_engine_configuration_json)
g2_engine.addRecordWithInfoWithReturnedRecordID(
datasource_code,
data_as_json,
response_bytearray,
record_id,
load_id)
g2_engine.destroy()
print(record_id.decode())
print(response_bytearray.decode())
except G2Exception as err:
print(err)
Output
06C29624478FF1C3285E294E5657796E3A67244A
{
"DATA_SOURCE": "TEST",
"RECORD_ID": "06C29624478FF1C3285E294E5657796E3A67244A",
"AFFECTED_ENTITIES": [
{
"ENTITY_ID": 1
}
],
"INTERESTING_ENTITIES": {
"ENTITIES": []
}
}
Replacing Records
replaceRecord
Currently a placeholder. Identical to to addRecord()
replaceRecordWithInfo
Currently a placeholder. Identical to to addrecordwithinfo()