Deleting Records
deleteRecord
deleteRecord() removes a record from the data repository.
deleteRecord() can be called as many times as desired and from multiple threads at the same time.
g2_engine.deleteRecord(datasource_code, record_id, load_id)
Parameters
- datasource_code: (str) The configured data source for the record.
- record_id: (str) The RECORD_ID for the record.
- load_id: (str [optional] ) the observation load ID for the record. The value can be null.
Click to expand `deleteRecord()` 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 = 'Delete Record CUSTOMERS 1001'
try:
g2_engine.init("G2Engine", senzing_engine_configuration_json)
g2_engine.deleteRecord(
datasource_code,
record_id,
load_id)
g2_engine.destroy()
except G2Exception as err:
print(err)
deleteRecordWithInfo
deleteRecordWithInfo() behaves the same as deleteRecord(), but also returns a JSON document containing the IDs of the affected entities.
g2_engine.deleteRecordWithInfo(datasource_code, record_id, response_bytearray, load_id)
Parameters
- datasource_code: (str) The configured data source for the record.
- record_id: (str) The RECORD_ID 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 `deleteRecordWithInfo()` 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'
response_bytearray = bytearray()
load_id = 'Delete Record CUSTOMERS 1001'
try:
g2_engine.init("G2Engine", senzing_engine_configuration_json)
g2_engine.deleteRecordWithInfo(
datasource_code,
record_id,
response_bytearray,
load_id)
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":
[]
}
}