Senzing in 3 Python Calls

This is a simple example of how to add and search Senzing 3.x via the Python SDK.

Prerequisites

Python example

#! /usr/bin/env python3

from senzing import G2Engine, G2Exception

# REPLACE /home/user/your_project with the path to your Senzing project
senzing_config_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" } }'

record = '{ "NAME_FULL": "ROBERT SMITH", "ADDR_FULL": "123 Main St, Las Vegas NV" }'

try:

  # Initialize the G2Engine
  g2 = G2Engine()
  g2.init("DoIT",config,False)

  # Entity resolve a record
  g2.addRecord("TEST","1",record)

  # Get the entity it resolved to
  response = bytearray()
  g2.getEntityByRecordID("TEST","1",response)

  # Display entity JSON
  print(response.decode())

  # Search for entities
  g2.searchByAttributes('{ "NAME_FIRST": "ROBERT", "NAME_LAST": "SMITH", "ADDR_FULL": "123 Main St, Las Vegas NV" }', response)

  # Display result JSON
  print(response.decode())

except Exception as err:
  print(err)