Updated: 9/4/2024
Signed in as:
filler@godaddy.com
Updated: 9/4/2024
Signed in as:
filler@godaddy.com
Tables in gDS can be built from collections of Python “lists.” Each Python list is a column of data in the table. For example:
gPerson_Name = []
gPerson_DOB = []
gPerson_SSN = []
gPerson_RowStatus = []
Python practitioners can see the above code contains no “special” Python syntax. The variables are not special in any way — it's just a plain-vanilla declaration of 4 ordinary lists.
In order to make lists / tables in shared memory, one does the following:
from multiprocessing import Manager
gDSMgr = Manager()
gPerson_Name = gDSMgr.list()
gPerson_DOB = gDSMgr.list()
gPerson_SSN = gDSMgr.list()
gPerson_RowStatus = gDSMgr.list()
The code above creates four list variables in shared memory. The variables do not need to be cited in a Python “global” statement to be used anywhere in the running program or its spawned threads and processes.
To add one “row” of data to the above table/set of lists, use the Python “append” method just like a regular list:
gPerson_Name.append("Tom")
gPerson_DOB.append("1/1/1970")
gPerson_SSN.append("100-20-0300")
gPerson_RowStatus.append(None)
The above table is considered to contain one row of data, and that data is said to reside at “offset zero.” To print one column of that one new row of data:
print (gPerson_SSN[0])
To print out all the data in the table above, one would write in Python:
for personRef in range(len(gPerson_RowStatus)):
print (gPerson_Name[personRef],
gPerson_DOB[personRef],
gPerson_SSN[personRef])
Copyright © 2024 Testing Complex Systems - All Rights Reserved.
Powered by GoDaddy