Here is a Python script, using Tau Adaptor principles and libraries, to transfer the latest updates from the Customer table in a DEX database to the corresponding table in the BellHawk database. DEX is a simplified mirror database for the BellHawk database. It is typically installed as a SQL Server database on a Windows server computer on the same LAN as WIPtracker and is used as a simplified way for external systems to exchange data with a BellHawk database.
#Transfers Customer Data from DEX database to BellHawk database
1 mxp = iap_initialize()
2 BHinst = MXPclass("Customer","BellHawk") # BellHawk Adaptor Class Instance
3 DEXinst = MXPclass("DEX2BH-Customer","DEX") # DEX Adaptor Class Instance
4 n = DEXinst.Fetch("Latest") #Fetch New or Updted Records
5 for i in range(n):
6 # get next Customer HLDO instance as JSON string from DEX and convert to Dict
7 DEXcust = json.loads(DEXinst.GetNext())
8 BHcust = {} # create empty dictionary
9 BHcust["CustomerNumber"] = DEXcust["CustomerNumber"]
10 BHCust["CustomerName"] = DEXcust["CustomerName"]
11 # store Customer data into BellHawk database by converting to JSON sting
12 success = BHInst.Store(json.dumps(BHcust), "C")
Here:
The important thing to realize is that all the person writing the script needs to know is the adaptor names for the two databases, the names of the HLDOs corresponding to the tables in question and the parameter names, corresponding the the filed names. They do not need to know anything about the underlying structure of the databases, or whether a database field is a direct of indirect reference to the data, or whether the record already exists and needs updating or a new record needs to be created. This is all taken care of by the Tau Adaptor libraries.
These libraries also track when a user or intelligent agent or external system last accessed a record. They are then able to automate the fetching of just the latest updates to a database table for that user, agent, or external system.
In the following sections, we will learn how the adaptors and HLDOs are defined and provide the link to physical database records. Please click here to learn about Database Adaptors.